deCONZ dependency exports type hints (#70449)

This commit is contained in:
Robert Svensson 2022-04-23 07:27:47 +02:00 committed by GitHub
parent a29265e725
commit 678888c65f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 29 additions and 29 deletions

View file

@ -163,7 +163,7 @@ ENTITY_DESCRIPTIONS = {
BINARY_SENSOR_DESCRIPTIONS = [ BINARY_SENSOR_DESCRIPTIONS = [
DeconzBinarySensorDescription( DeconzBinarySensorDescription(
key="tampered", key="tampered",
value_fn=lambda device: device.tampered, # type: ignore[no-any-return] value_fn=lambda device: device.tampered,
suffix="Tampered", suffix="Tampered",
update_key="tampered", update_key="tampered",
device_class=BinarySensorDeviceClass.TAMPER, device_class=BinarySensorDeviceClass.TAMPER,
@ -171,7 +171,7 @@ BINARY_SENSOR_DESCRIPTIONS = [
), ),
DeconzBinarySensorDescription( DeconzBinarySensorDescription(
key="low_battery", key="low_battery",
value_fn=lambda device: device.low_battery, # type: ignore[no-any-return] value_fn=lambda device: device.low_battery,
suffix="Low Battery", suffix="Low Battery",
update_key="lowbattery", update_key="lowbattery",
device_class=BinarySensorDeviceClass.BATTERY, device_class=BinarySensorDeviceClass.BATTERY,

View file

@ -228,16 +228,16 @@ class DeconzThermostat(DeconzDevice, ClimateEntity):
@property @property
def current_temperature(self) -> float: def current_temperature(self) -> float:
"""Return the current temperature.""" """Return the current temperature."""
return self._device.scaled_temperature # type: ignore[no-any-return] return self._device.scaled_temperature
@property @property
def target_temperature(self) -> float | None: def target_temperature(self) -> float | None:
"""Return the target temperature.""" """Return the target temperature."""
if self._device.mode == THERMOSTAT_MODE_COOL and self._device.cooling_setpoint: if self._device.mode == THERMOSTAT_MODE_COOL and self._device.cooling_setpoint:
return self._device.cooling_setpoint # type: ignore[no-any-return] return self._device.cooling_setpoint
if self._device.heating_setpoint: if self._device.heating_setpoint:
return self._device.heating_setpoint # type: ignore[no-any-return] return self._device.heating_setpoint
return None return None

View file

@ -92,7 +92,7 @@ class DeconzCover(DeconzDevice, CoverEntity):
@property @property
def current_cover_position(self) -> int: def current_cover_position(self) -> int:
"""Return the current position of the cover.""" """Return the current position of the cover."""
return 100 - self._device.lift # type: ignore[no-any-return] return 100 - self._device.lift
@property @property
def is_closed(self) -> bool: def is_closed(self) -> bool:
@ -120,7 +120,7 @@ class DeconzCover(DeconzDevice, CoverEntity):
def current_cover_tilt_position(self) -> int | None: def current_cover_tilt_position(self) -> int | None:
"""Return the current tilt position of the cover.""" """Return the current tilt position of the cover."""
if self._device.tilt is not None: if self._device.tilt is not None:
return 100 - self._device.tilt # type: ignore[no-any-return] return 100 - self._device.tilt
return None return None
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None: async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:

View file

@ -31,7 +31,7 @@ class DeconzBase:
def unique_id(self) -> str: def unique_id(self) -> str:
"""Return a unique identifier for this device.""" """Return a unique identifier for this device."""
assert not isinstance(self._device, PydeconzScene) assert not isinstance(self._device, PydeconzScene)
return self._device.unique_id # type: ignore[no-any-return] return self._device.unique_id
@property @property
def serial(self) -> str | None: def serial(self) -> str | None:
@ -39,7 +39,7 @@ class DeconzBase:
assert not isinstance(self._device, PydeconzScene) assert not isinstance(self._device, PydeconzScene)
if not self._device.unique_id or self._device.unique_id.count(":") != 7: if not self._device.unique_id or self._device.unique_id.count(":") != 7:
return None return None
return self._device.unique_id.split("-", 1)[0] # type: ignore[no-any-return] return self._device.unique_id.split("-", 1)[0]
@property @property
def device_info(self) -> DeviceInfo | None: def device_info(self) -> DeviceInfo | None:

View file

@ -92,7 +92,7 @@ class DeconzFan(DeconzDevice, FanEntity):
@property @property
def is_on(self) -> bool: def is_on(self) -> bool:
"""Return true if fan is on.""" """Return true if fan is on."""
return self._device.speed != FAN_SPEED_OFF # type: ignore[no-any-return] return self._device.speed != FAN_SPEED_OFF
@property @property
def percentage(self) -> int | None: def percentage(self) -> int | None:

View file

@ -186,12 +186,12 @@ class DeconzBaseLight(Generic[_L], DeconzDevice, LightEntity):
@property @property
def brightness(self) -> int | None: def brightness(self) -> int | None:
"""Return the brightness of this light between 0..255.""" """Return the brightness of this light between 0..255."""
return self._device.brightness # type: ignore[no-any-return] return self._device.brightness
@property @property
def color_temp(self) -> int | None: def color_temp(self) -> int | None:
"""Return the CT color value.""" """Return the CT color value."""
return self._device.color_temp # type: ignore[no-any-return] return self._device.color_temp
@property @property
def hs_color(self) -> tuple[float, float] | None: def hs_color(self) -> tuple[float, float] | None:
@ -203,12 +203,12 @@ class DeconzBaseLight(Generic[_L], DeconzDevice, LightEntity):
@property @property
def xy_color(self) -> tuple[float, float] | None: def xy_color(self) -> tuple[float, float] | None:
"""Return the XY color value.""" """Return the XY color value."""
return self._device.xy # type: ignore[no-any-return] return self._device.xy
@property @property
def is_on(self) -> bool | None: def is_on(self) -> bool | None:
"""Return true if light is on.""" """Return true if light is on."""
return self._device.state # type: ignore[no-any-return] return self._device.state
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on light.""" """Turn on light."""

View file

@ -93,7 +93,7 @@ class DeconzLock(DeconzDevice, LockEntity):
@property @property
def is_locked(self) -> bool: def is_locked(self) -> bool:
"""Return true if lock is on.""" """Return true if lock is on."""
return self._device.is_locked # type: ignore[no-any-return] return self._device.is_locked
async def async_lock(self, **kwargs: Any) -> None: async def async_lock(self, **kwargs: Any) -> None:
"""Lock the lock.""" """Lock the lock."""

View file

@ -3,7 +3,7 @@
"name": "deCONZ", "name": "deCONZ",
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/deconz", "documentation": "https://www.home-assistant.io/integrations/deconz",
"requirements": ["pydeconz==88"], "requirements": ["pydeconz==90"],
"ssdp": [ "ssdp": [
{ {
"manufacturer": "Royal Philips Electronics" "manufacturer": "Royal Philips Electronics"

View file

@ -28,7 +28,7 @@ class DeconzNumberDescriptionMixin:
suffix: str suffix: str
update_key: str update_key: str
value_fn: Callable[[Presence], float] value_fn: Callable[[Presence], float | None]
@dataclass @dataclass
@ -40,7 +40,7 @@ ENTITY_DESCRIPTIONS = {
Presence: [ Presence: [
DeconzNumberDescription( DeconzNumberDescription(
key="delay", key="delay",
value_fn=lambda device: device.delay, # type: ignore[no-any-return] value_fn=lambda device: device.delay,
suffix="Delay", suffix="Delay",
update_key=PRESENCE_DELAY, update_key=PRESENCE_DELAY,
max_value=65535, max_value=65535,
@ -100,7 +100,7 @@ async def async_setup_entry(
async_add_sensor( async_add_sensor(
[ [
gateway.api.sensors[key] gateway.api.sensors.presence[key]
for key in sorted(gateway.api.sensors.presence, key=int) for key in sorted(gateway.api.sensors.presence, key=int)
] ]
) )
@ -132,7 +132,7 @@ class DeconzNumber(DeconzDevice, NumberEntity):
super().async_update_callback() super().async_update_callback()
@property @property
def value(self) -> float: def value(self) -> float | None:
"""Return the value of the sensor property.""" """Return the value of the sensor property."""
return self.entity_description.value_fn(self._device) return self.entity_description.value_fn(self._device)

View file

@ -216,7 +216,7 @@ ENTITY_DESCRIPTIONS = {
SENSOR_DESCRIPTIONS = [ SENSOR_DESCRIPTIONS = [
DeconzSensorDescription( DeconzSensorDescription(
key="battery", key="battery",
value_fn=lambda device: device.battery, # type: ignore[no-any-return] value_fn=lambda device: device.battery,
suffix="Battery", suffix="Battery",
update_key="battery", update_key="battery",
device_class=SensorDeviceClass.BATTERY, device_class=SensorDeviceClass.BATTERY,
@ -226,7 +226,7 @@ SENSOR_DESCRIPTIONS = [
), ),
DeconzSensorDescription( DeconzSensorDescription(
key="secondary_temperature", key="secondary_temperature",
value_fn=lambda device: device.secondary_temperature, # type: ignore[no-any-return] value_fn=lambda device: device.secondary_temperature,
suffix="Temperature", suffix="Temperature",
update_key="temperature", update_key="temperature",
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
@ -354,9 +354,9 @@ class DeconzSensor(DeconzDevice, SensorEntity):
def native_value(self) -> StateType | datetime: def native_value(self) -> StateType | datetime:
"""Return the state of the sensor.""" """Return the state of the sensor."""
if self.entity_description.device_class is SensorDeviceClass.TIMESTAMP: if self.entity_description.device_class is SensorDeviceClass.TIMESTAMP:
return dt_util.parse_datetime( value = self.entity_description.value_fn(self._device)
self.entity_description.value_fn(self._device) # type: ignore[arg-type] assert isinstance(value, str)
) return dt_util.parse_datetime(value)
return self.entity_description.value_fn(self._device) return self.entity_description.value_fn(self._device)
@property @property

View file

@ -73,7 +73,7 @@ class DeconzSiren(DeconzDevice, SirenEntity):
@property @property
def is_on(self) -> bool: def is_on(self) -> bool:
"""Return true if siren is on.""" """Return true if siren is on."""
return self._device.is_on # type: ignore[no-any-return] return self._device.is_on
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on siren.""" """Turn on siren."""

View file

@ -80,7 +80,7 @@ class DeconzPowerPlug(DeconzDevice, SwitchEntity):
@property @property
def is_on(self) -> bool: def is_on(self) -> bool:
"""Return true if switch is on.""" """Return true if switch is on."""
return self._device.on # type: ignore[no-any-return] return self._device.on
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on switch.""" """Turn on switch."""

View file

@ -1426,7 +1426,7 @@ pydaikin==2.7.0
pydanfossair==0.1.0 pydanfossair==0.1.0
# homeassistant.components.deconz # homeassistant.components.deconz
pydeconz==88 pydeconz==90
# homeassistant.components.delijn # homeassistant.components.delijn
pydelijn==1.0.0 pydelijn==1.0.0

View file

@ -947,7 +947,7 @@ pycoolmasternet-async==0.1.2
pydaikin==2.7.0 pydaikin==2.7.0
# homeassistant.components.deconz # homeassistant.components.deconz
pydeconz==88 pydeconz==90
# homeassistant.components.dexcom # homeassistant.components.dexcom
pydexcom==0.2.3 pydexcom==0.2.3