"""
Simulated sensors for Sentinel.
"""

import random

from sentinel.sensors.base import CurrentSensor, TemperatureSensor


class SimulatedTemperatureSensor(TemperatureSensor):
    """
    Simulate a temperature sensor for development and testing.
    """

    def __init__(
        self,
        reference_temperature_c: float,
        variation_c: float = 0.2,
    ) -> None:
        self._reference_temperature_c = reference_temperature_c
        self._variation_c = variation_c

    def read_temperature_c(self) -> float:
        variation = random.uniform(
            -self._variation_c,
            self._variation_c,
        )

        return round(
            self._reference_temperature_c + variation,
            2,
        )


class SimulatedCurrentSensor(CurrentSensor):
    """
    Simulate an electrical current sensor.
    """

    def __init__(
        self,
        reference_current_a: float,
        variation_a: float = 0.05,
    ) -> None:
        self._reference_current_a = reference_current_a
        self._variation_a = variation_a

    def read_current_a(self) -> float:
        variation = random.uniform(
            -self._variation_a,
            self._variation_a,
        )

        return round(
            self._reference_current_a + variation,
            3,
        )