def test_wrong_value_type(self):
     """Test initializing with wrong value_type."""
     xknx = XKNX()
     with pytest.raises(ConversionError):
         RemoteValueNumeric(xknx=xknx, value_type="string")
     with pytest.raises(ConversionError):
         RemoteValueNumeric(xknx=xknx, value_type=16)
     with pytest.raises(ConversionError):
         RemoteValueNumeric(xknx=xknx, value_type="binary")
     with pytest.raises(ConversionError):
         RemoteValueNumeric(xknx=xknx)
Exemple #2
0
 def __init__(
     self,
     xknx: XKNX,
     name: str,
     group_address: GroupAddressesType | None = None,
     group_address_state: GroupAddressesType | None = None,
     respond_to_read: bool = False,
     sync_state: bool | int | float | str = True,
     value_type: int | str | None = None,
     always_callback: bool = False,
     device_updated_cb: DeviceCallbackType | None = None,
 ):
     """Initialize Sensor class."""
     super().__init__(xknx, name, device_updated_cb)
     self.always_callback = always_callback
     self.respond_to_read = respond_to_read
     self.sensor_value = RemoteValueNumeric(
         xknx,
         group_address=group_address,
         group_address_state=group_address_state,
         sync_state=sync_state,
         value_type=value_type,
         device_name=self.name,
         after_update_cb=self.after_update,
     )
Exemple #3
0
    def __init__(
        self,
        xknx: XKNX,
        name: str,
        group_address_temperature: GroupAddressesType | None = None,
        group_address_brightness_south: GroupAddressesType | None = None,
        group_address_brightness_north: GroupAddressesType | None = None,
        group_address_brightness_west: GroupAddressesType | None = None,
        group_address_brightness_east: GroupAddressesType | None = None,
        group_address_wind_speed: GroupAddressesType | None = None,
        group_address_wind_bearing: GroupAddressesType | None = None,
        group_address_rain_alarm: GroupAddressesType | None = None,
        group_address_frost_alarm: GroupAddressesType | None = None,
        group_address_wind_alarm: GroupAddressesType | None = None,
        group_address_day_night: GroupAddressesType | None = None,
        group_address_air_pressure: GroupAddressesType | None = None,
        group_address_humidity: GroupAddressesType | None = None,
        sync_state: bool | int | float | str = True,
        device_updated_cb: DeviceCallbackType | None = None,
    ) -> None:
        """Initialize Weather class."""
        super().__init__(xknx, name, device_updated_cb)

        self._temperature = RemoteValueNumeric(
            xknx,
            group_address_state=group_address_temperature,
            sync_state=sync_state,
            value_type="temperature",
            device_name=self.name,
            feature_name="Temperature",
            after_update_cb=self.after_update,
        )

        self._brightness_south = RemoteValueNumeric(
            xknx,
            group_address_state=group_address_brightness_south,
            sync_state=sync_state,
            value_type="illuminance",
            device_name=self.name,
            feature_name="Brightness south",
            after_update_cb=self.after_update,
        )

        self._brightness_north = RemoteValueNumeric(
            xknx,
            group_address_state=group_address_brightness_north,
            sync_state=sync_state,
            value_type="illuminance",
            device_name=self.name,
            feature_name="Brightness north",
            after_update_cb=self.after_update,
        )

        self._brightness_west = RemoteValueNumeric(
            xknx,
            group_address_state=group_address_brightness_west,
            sync_state=sync_state,
            value_type="illuminance",
            device_name=self.name,
            feature_name="Brightness west",
            after_update_cb=self.after_update,
        )

        self._brightness_east = RemoteValueNumeric(
            xknx,
            group_address_state=group_address_brightness_east,
            sync_state=sync_state,
            value_type="illuminance",
            device_name=self.name,
            feature_name="Brightness east",
            after_update_cb=self.after_update,
        )

        self._wind_speed = RemoteValueNumeric(
            xknx,
            group_address_state=group_address_wind_speed,
            sync_state=sync_state,
            value_type="wind_speed_ms",
            device_name=self.name,
            feature_name="Wind speed",
            after_update_cb=self.after_update,
        )

        self._wind_bearing = RemoteValueNumeric(
            xknx,
            group_address_state=group_address_wind_bearing,
            sync_state=sync_state,
            value_type="angle",
            device_name=self.name,
            feature_name="Wind bearing",
            after_update_cb=self.after_update,
        )

        self._rain_alarm = RemoteValueSwitch(
            xknx,
            group_address_state=group_address_rain_alarm,
            sync_state=sync_state,
            device_name=self.name,
            feature_name="Rain alarm",
            after_update_cb=self.after_update,
        )

        self._frost_alarm = RemoteValueSwitch(
            xknx,
            group_address_state=group_address_frost_alarm,
            sync_state=sync_state,
            device_name=self.name,
            feature_name="Frost alarm",
            after_update_cb=self.after_update,
        )

        self._wind_alarm = RemoteValueSwitch(
            xknx,
            group_address_state=group_address_wind_alarm,
            sync_state=sync_state,
            device_name=self.name,
            feature_name="Wind alarm",
            after_update_cb=self.after_update,
        )

        self._day_night = RemoteValueSwitch(
            xknx,
            group_address_state=group_address_day_night,
            sync_state=sync_state,
            device_name=self.name,
            feature_name="Day/Night",
            after_update_cb=self.after_update,
        )

        self._air_pressure = RemoteValueNumeric(
            xknx,
            group_address_state=group_address_air_pressure,
            sync_state=sync_state,
            value_type="pressure_2byte",
            device_name=self.name,
            feature_name="Air pressure",
            after_update_cb=self.after_update,
        )

        self._humidity = RemoteValueNumeric(
            xknx,
            group_address_state=group_address_humidity,
            sync_state=sync_state,
            value_type="humidity",
            device_name=self.name,
            feature_name="Humidity",
            after_update_cb=self.after_update,
        )
 def test_value_type(self):
     """Test initializing a value_type."""
     xknx = XKNX()
     assert RemoteValueNumeric(xknx=xknx, value_type="pulse")
     assert RemoteValueNumeric(xknx=xknx, value_type=9)
     assert RemoteValueNumeric(xknx=xknx, value_type="9.021")