Improve entity type hints [o] (#77826)
parent
d6ca3544ee
commit
ea71a462d6
|
@ -127,7 +127,7 @@ class OASATelematicsSensor(SensorEntity):
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Icon to use in the frontend, if any."""
|
||||||
return ICON
|
return ICON
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data from OASA API and update the states."""
|
"""Get the latest data from OASA API and update the states."""
|
||||||
self.data.update()
|
self.data.update()
|
||||||
self._times = self.data.info
|
self._times = self.data.info
|
||||||
|
|
|
@ -146,7 +146,7 @@ class ObihaiServiceSensors(SensorEntity):
|
||||||
return "mdi:restart-alert"
|
return "mdi:restart-alert"
|
||||||
return "mdi:phone"
|
return "mdi:phone"
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update the sensor."""
|
"""Update the sensor."""
|
||||||
services = self._pyobihai.get_state()
|
services = self._pyobihai.get_state()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"""OpenEnergyMonitor Thermostat Support."""
|
"""OpenEnergyMonitor Thermostat Support."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from oemthermostat import Thermostat
|
from oemthermostat import Thermostat
|
||||||
import requests
|
import requests
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -122,12 +124,12 @@ class ThermostatDevice(ClimateEntity):
|
||||||
elif hvac_mode == HVACMode.OFF:
|
elif hvac_mode == HVACMode.OFF:
|
||||||
self.thermostat.mode = 0
|
self.thermostat.mode = 0
|
||||||
|
|
||||||
def set_temperature(self, **kwargs):
|
def set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set the temperature."""
|
"""Set the temperature."""
|
||||||
temp = kwargs.get(ATTR_TEMPERATURE)
|
temp = kwargs.get(ATTR_TEMPERATURE)
|
||||||
self.thermostat.setpoint = temp
|
self.thermostat.setpoint = temp
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update local state."""
|
"""Update local state."""
|
||||||
self._setpoint = self.thermostat.setpoint
|
self._setpoint = self.thermostat.setpoint
|
||||||
self._temperature = self.thermostat.temperature
|
self._temperature = self.thermostat.temperature
|
||||||
|
|
|
@ -70,7 +70,7 @@ class OhmconnectSensor(SensorEntity):
|
||||||
return {"Address": self._data.get("address"), "ID": self._ohmid}
|
return {"Address": self._data.get("address"), "ID": self._ohmid}
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data from OhmConnect."""
|
"""Get the latest data from OhmConnect."""
|
||||||
try:
|
try:
|
||||||
url = f"https://login.ohmconnect.com/verify-ohm-hour/{self._ohmid}"
|
url = f"https://login.ohmconnect.com/verify-ohm-hour/{self._ohmid}"
|
||||||
|
|
|
@ -45,7 +45,7 @@ class OmbiSensor(SensorEntity):
|
||||||
|
|
||||||
self._attr_name = f"Ombi {description.name}"
|
self._attr_name = f"Ombi {description.name}"
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update the sensor."""
|
"""Update the sensor."""
|
||||||
try:
|
try:
|
||||||
sensor_type = self.entity_description.key
|
sensor_type = self.entity_description.key
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import eiscp
|
import eiscp
|
||||||
from eiscp import eISCP
|
from eiscp import eISCP
|
||||||
|
@ -295,7 +296,7 @@ class OnkyoDevice(MediaPlayerEntity):
|
||||||
_LOGGER.debug("Result for %s: %s", command, result)
|
_LOGGER.debug("Result for %s: %s", command, result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest state from the device."""
|
"""Get the latest state from the device."""
|
||||||
status = self.command("system-power query")
|
status = self.command("system-power query")
|
||||||
|
|
||||||
|
@ -396,11 +397,11 @@ class OnkyoDevice(MediaPlayerEntity):
|
||||||
"""Return device specific state attributes."""
|
"""Return device specific state attributes."""
|
||||||
return self._attributes
|
return self._attributes
|
||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self) -> None:
|
||||||
"""Turn the media player off."""
|
"""Turn the media player off."""
|
||||||
self.command("system-power standby")
|
self.command("system-power standby")
|
||||||
|
|
||||||
def set_volume_level(self, volume):
|
def set_volume_level(self, volume: float) -> None:
|
||||||
"""
|
"""
|
||||||
Set volume level, input is range 0..1.
|
Set volume level, input is range 0..1.
|
||||||
|
|
||||||
|
@ -414,32 +415,32 @@ class OnkyoDevice(MediaPlayerEntity):
|
||||||
f"volume {int(volume * (self._max_volume / 100) * self._receiver_max_volume)}"
|
f"volume {int(volume * (self._max_volume / 100) * self._receiver_max_volume)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def volume_up(self):
|
def volume_up(self) -> None:
|
||||||
"""Increase volume by 1 step."""
|
"""Increase volume by 1 step."""
|
||||||
self.command("volume level-up")
|
self.command("volume level-up")
|
||||||
|
|
||||||
def volume_down(self):
|
def volume_down(self) -> None:
|
||||||
"""Decrease volume by 1 step."""
|
"""Decrease volume by 1 step."""
|
||||||
self.command("volume level-down")
|
self.command("volume level-down")
|
||||||
|
|
||||||
def mute_volume(self, mute):
|
def mute_volume(self, mute: bool) -> None:
|
||||||
"""Mute (true) or unmute (false) media player."""
|
"""Mute (true) or unmute (false) media player."""
|
||||||
if mute:
|
if mute:
|
||||||
self.command("audio-muting on")
|
self.command("audio-muting on")
|
||||||
else:
|
else:
|
||||||
self.command("audio-muting off")
|
self.command("audio-muting off")
|
||||||
|
|
||||||
def turn_on(self):
|
def turn_on(self) -> None:
|
||||||
"""Turn the media player on."""
|
"""Turn the media player on."""
|
||||||
self.command("system-power on")
|
self.command("system-power on")
|
||||||
|
|
||||||
def select_source(self, source):
|
def select_source(self, source: str) -> None:
|
||||||
"""Set the input source."""
|
"""Set the input source."""
|
||||||
if source in self._source_list:
|
if source in self._source_list:
|
||||||
source = self._reverse_mapping[source]
|
source = self._reverse_mapping[source]
|
||||||
self.command(f"input-selector {source}")
|
self.command(f"input-selector {source}")
|
||||||
|
|
||||||
def play_media(self, media_type, media_id, **kwargs):
|
def play_media(self, media_type: str, media_id: str, **kwargs: Any) -> None:
|
||||||
"""Play radio station by preset number."""
|
"""Play radio station by preset number."""
|
||||||
source = self._reverse_mapping[self._current_source]
|
source = self._reverse_mapping[self._current_source]
|
||||||
if media_type.lower() == "radio" and source in DEFAULT_PLAYABLE_SOURCES:
|
if media_type.lower() == "radio" and source in DEFAULT_PLAYABLE_SOURCES:
|
||||||
|
@ -506,7 +507,7 @@ class OnkyoDeviceZone(OnkyoDevice):
|
||||||
self._supports_volume = True
|
self._supports_volume = True
|
||||||
super().__init__(receiver, sources, name, max_volume, receiver_max_volume)
|
super().__init__(receiver, sources, name, max_volume, receiver_max_volume)
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest state from the device."""
|
"""Get the latest state from the device."""
|
||||||
status = self.command(f"zone{self._zone}.power=query")
|
status = self.command(f"zone{self._zone}.power=query")
|
||||||
|
|
||||||
|
@ -563,11 +564,11 @@ class OnkyoDeviceZone(OnkyoDevice):
|
||||||
return SUPPORT_ONKYO
|
return SUPPORT_ONKYO
|
||||||
return SUPPORT_ONKYO_WO_VOLUME
|
return SUPPORT_ONKYO_WO_VOLUME
|
||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self) -> None:
|
||||||
"""Turn the media player off."""
|
"""Turn the media player off."""
|
||||||
self.command(f"zone{self._zone}.power=standby")
|
self.command(f"zone{self._zone}.power=standby")
|
||||||
|
|
||||||
def set_volume_level(self, volume):
|
def set_volume_level(self, volume: float) -> None:
|
||||||
"""
|
"""
|
||||||
Set volume level, input is range 0..1.
|
Set volume level, input is range 0..1.
|
||||||
|
|
||||||
|
@ -581,26 +582,26 @@ class OnkyoDeviceZone(OnkyoDevice):
|
||||||
f"zone{self._zone}.volume={int(volume * (self._max_volume / 100) * self._receiver_max_volume)}"
|
f"zone{self._zone}.volume={int(volume * (self._max_volume / 100) * self._receiver_max_volume)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def volume_up(self):
|
def volume_up(self) -> None:
|
||||||
"""Increase volume by 1 step."""
|
"""Increase volume by 1 step."""
|
||||||
self.command(f"zone{self._zone}.volume=level-up")
|
self.command(f"zone{self._zone}.volume=level-up")
|
||||||
|
|
||||||
def volume_down(self):
|
def volume_down(self) -> None:
|
||||||
"""Decrease volume by 1 step."""
|
"""Decrease volume by 1 step."""
|
||||||
self.command(f"zone{self._zone}.volume=level-down")
|
self.command(f"zone{self._zone}.volume=level-down")
|
||||||
|
|
||||||
def mute_volume(self, mute):
|
def mute_volume(self, mute: bool) -> None:
|
||||||
"""Mute (true) or unmute (false) media player."""
|
"""Mute (true) or unmute (false) media player."""
|
||||||
if mute:
|
if mute:
|
||||||
self.command(f"zone{self._zone}.muting=on")
|
self.command(f"zone{self._zone}.muting=on")
|
||||||
else:
|
else:
|
||||||
self.command(f"zone{self._zone}.muting=off")
|
self.command(f"zone{self._zone}.muting=off")
|
||||||
|
|
||||||
def turn_on(self):
|
def turn_on(self) -> None:
|
||||||
"""Turn the media player on."""
|
"""Turn the media player on."""
|
||||||
self.command(f"zone{self._zone}.power=on")
|
self.command(f"zone{self._zone}.power=on")
|
||||||
|
|
||||||
def select_source(self, source):
|
def select_source(self, source: str) -> None:
|
||||||
"""Set the input source."""
|
"""Set the input source."""
|
||||||
if source in self._source_list:
|
if source in self._source_list:
|
||||||
source = self._reverse_mapping[source]
|
source = self._reverse_mapping[source]
|
||||||
|
|
|
@ -82,7 +82,7 @@ class ONVIFBinarySensor(ONVIFBaseEntity, RestoreEntity, BinarySensorEntity):
|
||||||
return event.value
|
return event.value
|
||||||
return self._attr_is_on
|
return self._attr_is_on
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Connect to dispatcher listening for entity data notifications."""
|
"""Connect to dispatcher listening for entity data notifications."""
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
self.device.events.async_add_listener(self.async_write_ha_state)
|
self.device.events.async_add_listener(self.async_write_ha_state)
|
||||||
|
|
|
@ -81,7 +81,7 @@ class ONVIFSensor(ONVIFBaseEntity, RestoreSensor):
|
||||||
return event.value
|
return event.value
|
||||||
return self._attr_native_value
|
return self._attr_native_value
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Connect to dispatcher listening for entity data notifications."""
|
"""Connect to dispatcher listening for entity data notifications."""
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
self.device.events.async_add_listener(self.async_write_ha_state)
|
self.device.events.async_add_listener(self.async_write_ha_state)
|
||||||
|
|
|
@ -58,7 +58,7 @@ class OpenERZSensor(SensorEntity):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Fetch new state data for the sensor.
|
"""Fetch new state data for the sensor.
|
||||||
|
|
||||||
This is the only method that should fetch new data for Home Assistant.
|
This is the only method that should fetch new data for Home Assistant.
|
||||||
|
|
|
@ -118,7 +118,7 @@ class OpenEVSESensor(SensorEntity):
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self.charger = charger
|
self.charger = charger
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the monitored data from the charger."""
|
"""Get the monitored data from the charger."""
|
||||||
try:
|
try:
|
||||||
sensor_type = self.entity_description.key
|
sensor_type = self.entity_description.key
|
||||||
|
|
|
@ -91,7 +91,7 @@ class OpenHardwareMonitorDevice(SensorEntity):
|
||||||
"""In some locales a decimal numbers uses ',' instead of '.'."""
|
"""In some locales a decimal numbers uses ',' instead of '.'."""
|
||||||
return string.replace(",", ".")
|
return string.replace(",", ".")
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update the device from a new JSON object."""
|
"""Update the device from a new JSON object."""
|
||||||
self._data.update()
|
self._data.update()
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ from homeassistant.components.media_player import (
|
||||||
MediaPlayerEntityFeature,
|
MediaPlayerEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.components.media_player.browse_media import (
|
from homeassistant.components.media_player.browse_media import (
|
||||||
|
BrowseMedia,
|
||||||
async_process_play_media_url,
|
async_process_play_media_url,
|
||||||
)
|
)
|
||||||
from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC
|
from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC
|
||||||
|
@ -133,7 +134,7 @@ class OpenhomeDevice(MediaPlayerEntity):
|
||||||
"""Device is available."""
|
"""Device is available."""
|
||||||
return self._available
|
return self._available
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self) -> None:
|
||||||
"""Update state of device."""
|
"""Update state of device."""
|
||||||
try:
|
try:
|
||||||
self._in_standby = await self._device.is_in_standby()
|
self._in_standby = await self._device.is_in_standby()
|
||||||
|
@ -195,17 +196,19 @@ class OpenhomeDevice(MediaPlayerEntity):
|
||||||
self._available = False
|
self._available = False
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_turn_on(self):
|
async def async_turn_on(self) -> None:
|
||||||
"""Bring device out of standby."""
|
"""Bring device out of standby."""
|
||||||
await self._device.set_standby(False)
|
await self._device.set_standby(False)
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_turn_off(self):
|
async def async_turn_off(self) -> None:
|
||||||
"""Put device in standby."""
|
"""Put device in standby."""
|
||||||
await self._device.set_standby(True)
|
await self._device.set_standby(True)
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_play_media(self, media_type, media_id, **kwargs):
|
async def async_play_media(
|
||||||
|
self, media_type: str, media_id: str, **kwargs: Any
|
||||||
|
) -> None:
|
||||||
"""Send the play_media command to the media player."""
|
"""Send the play_media command to the media player."""
|
||||||
if media_source.is_media_source_id(media_id):
|
if media_source.is_media_source_id(media_id):
|
||||||
media_type = MEDIA_TYPE_MUSIC
|
media_type = MEDIA_TYPE_MUSIC
|
||||||
|
@ -228,32 +231,32 @@ class OpenhomeDevice(MediaPlayerEntity):
|
||||||
await self._device.play_media(track_details)
|
await self._device.play_media(track_details)
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_media_pause(self):
|
async def async_media_pause(self) -> None:
|
||||||
"""Send pause command."""
|
"""Send pause command."""
|
||||||
await self._device.pause()
|
await self._device.pause()
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_media_stop(self):
|
async def async_media_stop(self) -> None:
|
||||||
"""Send stop command."""
|
"""Send stop command."""
|
||||||
await self._device.stop()
|
await self._device.stop()
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_media_play(self):
|
async def async_media_play(self) -> None:
|
||||||
"""Send play command."""
|
"""Send play command."""
|
||||||
await self._device.play()
|
await self._device.play()
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_media_next_track(self):
|
async def async_media_next_track(self) -> None:
|
||||||
"""Send next track command."""
|
"""Send next track command."""
|
||||||
await self._device.skip(1)
|
await self._device.skip(1)
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_media_previous_track(self):
|
async def async_media_previous_track(self) -> None:
|
||||||
"""Send previous track command."""
|
"""Send previous track command."""
|
||||||
await self._device.skip(-1)
|
await self._device.skip(-1)
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_select_source(self, source):
|
async def async_select_source(self, source: str) -> None:
|
||||||
"""Select input source."""
|
"""Select input source."""
|
||||||
await self._device.set_source(self._source_index[source])
|
await self._device.set_source(self._source_index[source])
|
||||||
|
|
||||||
|
@ -325,26 +328,28 @@ class OpenhomeDevice(MediaPlayerEntity):
|
||||||
return self._volume_muted
|
return self._volume_muted
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_volume_up(self):
|
async def async_volume_up(self) -> None:
|
||||||
"""Volume up media player."""
|
"""Volume up media player."""
|
||||||
await self._device.increase_volume()
|
await self._device.increase_volume()
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_volume_down(self):
|
async def async_volume_down(self) -> None:
|
||||||
"""Volume down media player."""
|
"""Volume down media player."""
|
||||||
await self._device.decrease_volume()
|
await self._device.decrease_volume()
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_set_volume_level(self, volume):
|
async def async_set_volume_level(self, volume: float) -> None:
|
||||||
"""Set volume level, range 0..1."""
|
"""Set volume level, range 0..1."""
|
||||||
await self._device.set_volume(int(volume * 100))
|
await self._device.set_volume(int(volume * 100))
|
||||||
|
|
||||||
@catch_request_errors()
|
@catch_request_errors()
|
||||||
async def async_mute_volume(self, mute):
|
async def async_mute_volume(self, mute: bool) -> None:
|
||||||
"""Mute (true) or unmute (false) media player."""
|
"""Mute (true) or unmute (false) media player."""
|
||||||
await self._device.set_mute(mute)
|
await self._device.set_mute(mute)
|
||||||
|
|
||||||
async def async_browse_media(self, media_content_type=None, media_content_id=None):
|
async def async_browse_media(
|
||||||
|
self, media_content_type: str | None = None, media_content_id: str | None = None
|
||||||
|
) -> BrowseMedia:
|
||||||
"""Implement the websocket media browsing helper."""
|
"""Implement the websocket media browsing helper."""
|
||||||
return await media_source.async_browse_media(
|
return await media_source.async_browse_media(
|
||||||
self.hass,
|
self.hass,
|
||||||
|
|
|
@ -102,14 +102,14 @@ class OpenThermBinarySensor(BinarySensorEntity):
|
||||||
self._friendly_name = friendly_name_format.format(gw_dev.name)
|
self._friendly_name = friendly_name_format.format(gw_dev.name)
|
||||||
self._unsub_updates = None
|
self._unsub_updates = None
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Subscribe to updates from the component."""
|
"""Subscribe to updates from the component."""
|
||||||
_LOGGER.debug("Added OpenTherm Gateway binary sensor %s", self._friendly_name)
|
_LOGGER.debug("Added OpenTherm Gateway binary sensor %s", self._friendly_name)
|
||||||
self._unsub_updates = async_dispatcher_connect(
|
self._unsub_updates = async_dispatcher_connect(
|
||||||
self.hass, self._gateway.update_signal, self.receive_report
|
self.hass, self._gateway.update_signal, self.receive_report
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_will_remove_from_hass(self):
|
async def async_will_remove_from_hass(self) -> None:
|
||||||
"""Unsubscribe from updates from the component."""
|
"""Unsubscribe from updates from the component."""
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Removing OpenTherm Gateway binary sensor %s", self._friendly_name
|
"Removing OpenTherm Gateway binary sensor %s", self._friendly_name
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from pyotgw import vars as gw_vars
|
from pyotgw import vars as gw_vars
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ class OpenThermClimate(ClimateEntity):
|
||||||
self.temporary_ovrd_mode = entry.options[CONF_TEMPORARY_OVRD_MODE]
|
self.temporary_ovrd_mode = entry.options[CONF_TEMPORARY_OVRD_MODE]
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Connect to the OpenTherm Gateway device."""
|
"""Connect to the OpenTherm Gateway device."""
|
||||||
_LOGGER.debug("Added OpenTherm Gateway climate device %s", self.friendly_name)
|
_LOGGER.debug("Added OpenTherm Gateway climate device %s", self.friendly_name)
|
||||||
self._unsub_updates = async_dispatcher_connect(
|
self._unsub_updates = async_dispatcher_connect(
|
||||||
|
@ -111,7 +112,7 @@ class OpenThermClimate(ClimateEntity):
|
||||||
self.hass, self._gateway.options_update_signal, self.update_options
|
self.hass, self._gateway.options_update_signal, self.update_options
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_will_remove_from_hass(self):
|
async def async_will_remove_from_hass(self) -> None:
|
||||||
"""Unsubscribe from updates from the component."""
|
"""Unsubscribe from updates from the component."""
|
||||||
_LOGGER.debug("Removing OpenTherm Gateway climate %s", self.friendly_name)
|
_LOGGER.debug("Removing OpenTherm Gateway climate %s", self.friendly_name)
|
||||||
self._unsub_options()
|
self._unsub_options()
|
||||||
|
@ -261,11 +262,11 @@ class OpenThermClimate(ClimateEntity):
|
||||||
"""Available preset modes to set."""
|
"""Available preset modes to set."""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def set_preset_mode(self, preset_mode):
|
def set_preset_mode(self, preset_mode: str) -> None:
|
||||||
"""Set the preset mode."""
|
"""Set the preset mode."""
|
||||||
_LOGGER.warning("Changing preset mode is not supported")
|
_LOGGER.warning("Changing preset mode is not supported")
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs):
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if ATTR_TEMPERATURE in kwargs:
|
if ATTR_TEMPERATURE in kwargs:
|
||||||
temp = float(kwargs[ATTR_TEMPERATURE])
|
temp = float(kwargs[ATTR_TEMPERATURE])
|
||||||
|
|
|
@ -106,14 +106,14 @@ class OpenThermSensor(SensorEntity):
|
||||||
self._friendly_name = friendly_name_format.format(gw_dev.name)
|
self._friendly_name = friendly_name_format.format(gw_dev.name)
|
||||||
self._unsub_updates = None
|
self._unsub_updates = None
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Subscribe to updates from the component."""
|
"""Subscribe to updates from the component."""
|
||||||
_LOGGER.debug("Added OpenTherm Gateway sensor %s", self._friendly_name)
|
_LOGGER.debug("Added OpenTherm Gateway sensor %s", self._friendly_name)
|
||||||
self._unsub_updates = async_dispatcher_connect(
|
self._unsub_updates = async_dispatcher_connect(
|
||||||
self.hass, self._gateway.update_signal, self.receive_report
|
self.hass, self._gateway.update_signal, self.receive_report
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_will_remove_from_hass(self):
|
async def async_will_remove_from_hass(self) -> None:
|
||||||
"""Unsubscribe from updates from the component."""
|
"""Unsubscribe from updates from the component."""
|
||||||
_LOGGER.debug("Removing OpenTherm Gateway sensor %s", self._friendly_name)
|
_LOGGER.debug("Removing OpenTherm Gateway sensor %s", self._friendly_name)
|
||||||
self._unsub_updates()
|
self._unsub_updates()
|
||||||
|
|
|
@ -69,7 +69,7 @@ class OppleLight(LightEntity):
|
||||||
self._color_temp = None
|
self._color_temp = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self) -> bool:
|
||||||
"""Return True if light is available."""
|
"""Return True if light is available."""
|
||||||
return self._device.is_online
|
return self._device.is_online
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ class CurrentEnergyUsageSensor(SensorEntity):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Fetch new state data for the sensor."""
|
"""Fetch new state data for the sensor."""
|
||||||
try:
|
try:
|
||||||
last_read = self.meter.last_read()
|
last_read = self.meter.last_read()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from orvibo.s20 import S20, S20Exception, discover
|
from orvibo.s20 import S20, S20Exception, discover
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -93,21 +94,21 @@ class S20Switch(SwitchEntity):
|
||||||
"""Return true if device is on."""
|
"""Return true if device is on."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update device state."""
|
"""Update device state."""
|
||||||
try:
|
try:
|
||||||
self._state = self._s20.on
|
self._state = self._s20.on
|
||||||
except self._exc:
|
except self._exc:
|
||||||
_LOGGER.exception("Error while fetching S20 state")
|
_LOGGER.exception("Error while fetching S20 state")
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
try:
|
try:
|
||||||
self._s20.on = True
|
self._s20.on = True
|
||||||
except self._exc:
|
except self._exc:
|
||||||
_LOGGER.exception("Error while turning on S20")
|
_LOGGER.exception("Error while turning on S20")
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
try:
|
try:
|
||||||
self._s20.on = False
|
self._s20.on = False
|
||||||
|
|
|
@ -53,7 +53,7 @@ class TOTPSensor(SensorEntity):
|
||||||
self._state = None
|
self._state = None
|
||||||
self._next_expiration = None
|
self._next_expiration = None
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Handle when an entity is about to be added to Home Assistant."""
|
"""Handle when an entity is about to be added to Home Assistant."""
|
||||||
self._call_loop()
|
self._call_loop()
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ class OwnTracksEntity(TrackerEntity, RestoreEntity):
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return DeviceInfo(identifiers={(OT_DOMAIN, self._dev_id)}, name=self.name)
|
return DeviceInfo(identifiers={(OT_DOMAIN, self._dev_id)}, name=self.name)
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Call when entity about to be added to Home Assistant."""
|
"""Call when entity about to be added to Home Assistant."""
|
||||||
await super().async_added_to_hass()
|
await super().async_added_to_hass()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue