mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Use _attr_should_poll in components [s-t] (#77368)
* Use _attr_should_poll in components [s-t] * Adjust touchline Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
c916fcb2c6
commit
2b9116f1f8
@ -176,6 +176,8 @@ def async_track_time_interval_backoff(hass, action) -> CALLBACK_TYPE:
|
|||||||
class SAJsensor(SensorEntity):
|
class SAJsensor(SensorEntity):
|
||||||
"""Representation of a SAJ sensor."""
|
"""Representation of a SAJ sensor."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, serialnumber, pysaj_sensor, inverter_name=None):
|
def __init__(self, serialnumber, pysaj_sensor, inverter_name=None):
|
||||||
"""Initialize the SAJ sensor."""
|
"""Initialize the SAJ sensor."""
|
||||||
self._sensor = pysaj_sensor
|
self._sensor = pysaj_sensor
|
||||||
@ -216,11 +218,6 @@ class SAJsensor(SensorEntity):
|
|||||||
if self.native_unit_of_measurement in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
|
if self.native_unit_of_measurement in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
|
||||||
return SensorDeviceClass.TEMPERATURE
|
return SensorDeviceClass.TEMPERATURE
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self) -> bool:
|
|
||||||
"""SAJ sensors are updated & don't poll."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def per_day_basis(self) -> bool:
|
def per_day_basis(self) -> bool:
|
||||||
"""Return if the sensors value is on daily basis or not."""
|
"""Return if the sensors value is on daily basis or not."""
|
||||||
|
@ -60,6 +60,8 @@ async def async_setup_platform(
|
|||||||
class SatelIntegraBinarySensor(BinarySensorEntity):
|
class SatelIntegraBinarySensor(BinarySensorEntity):
|
||||||
"""Representation of an Satel Integra binary sensor."""
|
"""Representation of an Satel Integra binary sensor."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, controller, device_number, device_name, zone_type, react_to_signal
|
self, controller, device_number, device_name, zone_type, react_to_signal
|
||||||
):
|
):
|
||||||
@ -100,11 +102,6 @@ class SatelIntegraBinarySensor(BinarySensorEntity):
|
|||||||
if self._zone_type is BinarySensorDeviceClass.SMOKE:
|
if self._zone_type is BinarySensorDeviceClass.SMOKE:
|
||||||
return "mdi:fire"
|
return "mdi:fire"
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if sensor is on."""
|
"""Return true if sensor is on."""
|
||||||
|
@ -51,6 +51,8 @@ async def async_setup_platform(
|
|||||||
class SatelIntegraSwitch(SwitchEntity):
|
class SatelIntegraSwitch(SwitchEntity):
|
||||||
"""Representation of an Satel switch."""
|
"""Representation of an Satel switch."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, controller, device_number, device_name, code):
|
def __init__(self, controller, device_number, device_name, code):
|
||||||
"""Initialize the binary_sensor."""
|
"""Initialize the binary_sensor."""
|
||||||
self._device_number = device_number
|
self._device_number = device_number
|
||||||
@ -104,8 +106,3 @@ class SatelIntegraSwitch(SwitchEntity):
|
|||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the switch."""
|
"""Return the name of the switch."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Don't poll."""
|
|
||||||
return False
|
|
||||||
|
@ -59,6 +59,8 @@ def setup_platform(
|
|||||||
class SCSGateCover(CoverEntity):
|
class SCSGateCover(CoverEntity):
|
||||||
"""Representation of SCSGate cover."""
|
"""Representation of SCSGate cover."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, scs_id, name, logger, scsgate):
|
def __init__(self, scs_id, name, logger, scsgate):
|
||||||
"""Initialize the cover."""
|
"""Initialize the cover."""
|
||||||
self._scs_id = scs_id
|
self._scs_id = scs_id
|
||||||
@ -71,11 +73,6 @@ class SCSGateCover(CoverEntity):
|
|||||||
"""Return the SCSGate ID."""
|
"""Return the SCSGate ID."""
|
||||||
return self._scs_id
|
return self._scs_id
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self) -> bool:
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the cover."""
|
"""Return the name of the cover."""
|
||||||
|
@ -91,6 +91,8 @@ def _setup_scenario_switches(logger, config, scsgate, hass):
|
|||||||
class SCSGateSwitch(SwitchEntity):
|
class SCSGateSwitch(SwitchEntity):
|
||||||
"""Representation of a SCSGate switch."""
|
"""Representation of a SCSGate switch."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, scs_id, name, logger, scsgate):
|
def __init__(self, scs_id, name, logger, scsgate):
|
||||||
"""Initialize the switch."""
|
"""Initialize the switch."""
|
||||||
self._name = name
|
self._name = name
|
||||||
@ -104,11 +106,6 @@ class SCSGateSwitch(SwitchEntity):
|
|||||||
"""Return the SCS ID."""
|
"""Return the SCS ID."""
|
||||||
return self._scs_id
|
return self._scs_id
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the device if any."""
|
"""Return the name of the device if any."""
|
||||||
|
@ -73,6 +73,8 @@ def sense_to_mdi(sense_icon):
|
|||||||
class SenseDevice(BinarySensorEntity):
|
class SenseDevice(BinarySensorEntity):
|
||||||
"""Implementation of a Sense energy device binary sensor."""
|
"""Implementation of a Sense energy device binary sensor."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, sense_devices_data, device, sense_monitor_id):
|
def __init__(self, sense_devices_data, device, sense_monitor_id):
|
||||||
"""Initialize the Sense binary sensor."""
|
"""Initialize the Sense binary sensor."""
|
||||||
self._name = device["name"]
|
self._name = device["name"]
|
||||||
@ -124,11 +126,6 @@ class SenseDevice(BinarySensorEntity):
|
|||||||
"""Return the device class of the binary sensor."""
|
"""Return the device class of the binary sensor."""
|
||||||
return BinarySensorDeviceClass.POWER
|
return BinarySensorDeviceClass.POWER
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Return the deviceshould not poll for updates."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Register callbacks."""
|
"""Register callbacks."""
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
|
@ -113,6 +113,8 @@ async def async_setup_platform(
|
|||||||
class SerialSensor(SensorEntity):
|
class SerialSensor(SensorEntity):
|
||||||
"""Representation of a Serial sensor."""
|
"""Representation of a Serial sensor."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name,
|
name,
|
||||||
@ -242,11 +244,6 @@ class SerialSensor(SensorEntity):
|
|||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the attributes of the entity (if any JSON present)."""
|
"""Return the attributes of the entity (if any JSON present)."""
|
||||||
|
@ -86,6 +86,7 @@ def setup_platform(
|
|||||||
class SighthoundEntity(ImageProcessingEntity):
|
class SighthoundEntity(ImageProcessingEntity):
|
||||||
"""Create a sighthound entity."""
|
"""Create a sighthound entity."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
_attr_unit_of_measurement = ATTR_PEOPLE
|
_attr_unit_of_measurement = ATTR_PEOPLE
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -167,11 +168,6 @@ class SighthoundEntity(ImageProcessingEntity):
|
|||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Return the polling state."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the entity."""
|
"""Return the state of the entity."""
|
||||||
|
@ -405,6 +405,8 @@ class DeviceBroker:
|
|||||||
class SmartThingsEntity(Entity):
|
class SmartThingsEntity(Entity):
|
||||||
"""Defines a SmartThings entity."""
|
"""Defines a SmartThings entity."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, device: DeviceEntity) -> None:
|
def __init__(self, device: DeviceEntity) -> None:
|
||||||
"""Initialize the instance."""
|
"""Initialize the instance."""
|
||||||
self._device = device
|
self._device = device
|
||||||
@ -443,11 +445,6 @@ class SmartThingsEntity(Entity):
|
|||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return self._device.label
|
return self._device.label
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self) -> bool:
|
|
||||||
"""No polling needed for this device."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
|
@ -116,6 +116,7 @@ async def handle_set_latency(entity, service_call):
|
|||||||
class SnapcastGroupDevice(MediaPlayerEntity):
|
class SnapcastGroupDevice(MediaPlayerEntity):
|
||||||
"""Representation of a Snapcast group device."""
|
"""Representation of a Snapcast group device."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
MediaPlayerEntityFeature.VOLUME_MUTE
|
MediaPlayerEntityFeature.VOLUME_MUTE
|
||||||
| MediaPlayerEntityFeature.VOLUME_SET
|
| MediaPlayerEntityFeature.VOLUME_SET
|
||||||
@ -173,11 +174,6 @@ class SnapcastGroupDevice(MediaPlayerEntity):
|
|||||||
name = f"{self._group.friendly_name} {GROUP_SUFFIX}"
|
name = f"{self._group.friendly_name} {GROUP_SUFFIX}"
|
||||||
return {"friendly_name": name}
|
return {"friendly_name": name}
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Do not poll for state."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
async def async_select_source(self, source):
|
async def async_select_source(self, source):
|
||||||
"""Set input source."""
|
"""Set input source."""
|
||||||
streams = self._group.streams_by_name()
|
streams = self._group.streams_by_name()
|
||||||
@ -208,6 +204,7 @@ class SnapcastGroupDevice(MediaPlayerEntity):
|
|||||||
class SnapcastClientDevice(MediaPlayerEntity):
|
class SnapcastClientDevice(MediaPlayerEntity):
|
||||||
"""Representation of a Snapcast client device."""
|
"""Representation of a Snapcast client device."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
MediaPlayerEntityFeature.VOLUME_MUTE
|
MediaPlayerEntityFeature.VOLUME_MUTE
|
||||||
| MediaPlayerEntityFeature.VOLUME_SET
|
| MediaPlayerEntityFeature.VOLUME_SET
|
||||||
@ -276,11 +273,6 @@ class SnapcastClientDevice(MediaPlayerEntity):
|
|||||||
state_attrs["friendly_name"] = name
|
state_attrs["friendly_name"] = name
|
||||||
return state_attrs
|
return state_attrs
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Do not poll for state."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def latency(self):
|
def latency(self):
|
||||||
"""Latency for Client."""
|
"""Latency for Client."""
|
||||||
|
@ -89,6 +89,7 @@ async def async_setup_entry(
|
|||||||
class SongpalEntity(MediaPlayerEntity):
|
class SongpalEntity(MediaPlayerEntity):
|
||||||
"""Class representing a Songpal device."""
|
"""Class representing a Songpal device."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
MediaPlayerEntityFeature.VOLUME_SET
|
MediaPlayerEntityFeature.VOLUME_SET
|
||||||
| MediaPlayerEntityFeature.VOLUME_STEP
|
| MediaPlayerEntityFeature.VOLUME_STEP
|
||||||
@ -118,11 +119,6 @@ class SongpalEntity(MediaPlayerEntity):
|
|||||||
self._active_source = None
|
self._active_source = None
|
||||||
self._sources = {}
|
self._sources = {}
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Return True if the device should be polled."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Run when entity is added to hass."""
|
"""Run when entity is added to hass."""
|
||||||
await self.async_activate_websocket()
|
await self.async_activate_websocket()
|
||||||
|
@ -83,6 +83,8 @@ async def async_setup_entry(
|
|||||||
class SrpEntity(SensorEntity):
|
class SrpEntity(SensorEntity):
|
||||||
"""Implementation of a Srp Energy Usage sensor."""
|
"""Implementation of a Srp Energy Usage sensor."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, coordinator):
|
def __init__(self, coordinator):
|
||||||
"""Initialize the SrpEntity class."""
|
"""Initialize the SrpEntity class."""
|
||||||
self._name = SENSOR_NAME
|
self._name = SENSOR_NAME
|
||||||
@ -125,11 +127,6 @@ class SrpEntity(SensorEntity):
|
|||||||
return f"{self.coordinator.data:.2f}"
|
return f"{self.coordinator.data:.2f}"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No need to poll. Coordinator notifies entity of updates."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
|
@ -11,6 +11,8 @@ from .account import StarlineAccount, StarlineDevice
|
|||||||
class StarlineEntity(Entity):
|
class StarlineEntity(Entity):
|
||||||
"""StarLine base entity class."""
|
"""StarLine base entity class."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, account: StarlineAccount, device: StarlineDevice, key: str, name: str
|
self, account: StarlineAccount, device: StarlineDevice, key: str, name: str
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -21,11 +23,6 @@ class StarlineEntity(Entity):
|
|||||||
self._name = name
|
self._name = name
|
||||||
self._unsubscribe_api: Callable | None = None
|
self._unsubscribe_api: Callable | None = None
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
|
@ -57,6 +57,8 @@ async def async_setup_entry(
|
|||||||
class FolderSensor(SensorEntity):
|
class FolderSensor(SensorEntity):
|
||||||
"""A Syncthing folder sensor."""
|
"""A Syncthing folder sensor."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
STATE_ATTRIBUTES = {
|
STATE_ATTRIBUTES = {
|
||||||
"errors": "errors",
|
"errors": "errors",
|
||||||
"globalBytes": "global_bytes",
|
"globalBytes": "global_bytes",
|
||||||
@ -131,11 +133,6 @@ class FolderSensor(SensorEntity):
|
|||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Return the polling requirement for this sensor."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
|
@ -7,6 +7,8 @@ from .const import DEFAULT_NAME, DOMAIN, TADO_HOME, TADO_ZONE
|
|||||||
class TadoDeviceEntity(Entity):
|
class TadoDeviceEntity(Entity):
|
||||||
"""Base implementation for Tado device."""
|
"""Base implementation for Tado device."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, device_info):
|
def __init__(self, device_info):
|
||||||
"""Initialize a Tado device."""
|
"""Initialize a Tado device."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -27,11 +29,6 @@ class TadoDeviceEntity(Entity):
|
|||||||
via_device=(DOMAIN, self._device_info["serialNo"]),
|
via_device=(DOMAIN, self._device_info["serialNo"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Do not poll."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
class TadoHomeEntity(Entity):
|
class TadoHomeEntity(Entity):
|
||||||
"""Base implementation for Tado home."""
|
"""Base implementation for Tado home."""
|
||||||
@ -57,6 +54,8 @@ class TadoHomeEntity(Entity):
|
|||||||
class TadoZoneEntity(Entity):
|
class TadoZoneEntity(Entity):
|
||||||
"""Base implementation for Tado zone."""
|
"""Base implementation for Tado zone."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, zone_name, home_id, zone_id):
|
def __init__(self, zone_name, home_id, zone_id):
|
||||||
"""Initialize a Tado zone."""
|
"""Initialize a Tado zone."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -75,8 +74,3 @@ class TadoZoneEntity(Entity):
|
|||||||
model=TADO_ZONE,
|
model=TADO_ZONE,
|
||||||
suggested_area=self.zone_name,
|
suggested_area=self.zone_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Do not poll."""
|
|
||||||
return False
|
|
||||||
|
@ -25,6 +25,8 @@ ATTR_LAST_UPDATED = "time_last_updated"
|
|||||||
class TelldusLiveEntity(Entity):
|
class TelldusLiveEntity(Entity):
|
||||||
"""Base class for all Telldus Live entities."""
|
"""Base class for all Telldus Live entities."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, client, device_id):
|
def __init__(self, client, device_id):
|
||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
self._id = device_id
|
self._id = device_id
|
||||||
@ -66,11 +68,6 @@ class TelldusLiveEntity(Entity):
|
|||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
return self.device.state
|
return self.device.state
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Return the polling state."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def assumed_state(self):
|
def assumed_state(self):
|
||||||
"""Return true if unable to access real state of entity."""
|
"""Return true if unable to access real state of entity."""
|
||||||
|
@ -112,6 +112,8 @@ async def async_setup_platform(
|
|||||||
class ThresholdSensor(BinarySensorEntity):
|
class ThresholdSensor(BinarySensorEntity):
|
||||||
"""Representation of a Threshold sensor."""
|
"""Representation of a Threshold sensor."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass, entity_id, name, lower, upper, hysteresis, device_class, unique_id
|
self, hass, entity_id, name, lower, upper, hysteresis, device_class, unique_id
|
||||||
):
|
):
|
||||||
@ -168,11 +170,6 @@ class ThresholdSensor(BinarySensorEntity):
|
|||||||
"""Return true if sensor is on."""
|
"""Return true if sensor is on."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the sensor class of the sensor."""
|
"""Return the sensor class of the sensor."""
|
||||||
|
@ -98,6 +98,8 @@ def _is_sun_event(sun_event):
|
|||||||
class TodSensor(BinarySensorEntity):
|
class TodSensor(BinarySensorEntity):
|
||||||
"""Time of the Day Sensor."""
|
"""Time of the Day Sensor."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, name, after, after_offset, before, before_offset, unique_id):
|
def __init__(self, name, after, after_offset, before, before_offset, unique_id):
|
||||||
"""Init the ToD Sensor..."""
|
"""Init the ToD Sensor..."""
|
||||||
self._attr_unique_id = unique_id
|
self._attr_unique_id = unique_id
|
||||||
@ -109,11 +111,6 @@ class TodSensor(BinarySensorEntity):
|
|||||||
self._after = after
|
self._after = after
|
||||||
self._unsub_update: Callable[[], None] = None
|
self._unsub_update: Callable[[], None] = None
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Sensor does not need to be polled."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
|
@ -84,11 +84,6 @@ class Touchline(ClimateEntity):
|
|||||||
(self.unit.get_operation_mode(), self.unit.get_week_program())
|
(self.unit.get_operation_mode(), self.unit.get_week_program())
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Return the polling state."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the climate device."""
|
"""Return the name of the climate device."""
|
||||||
|
@ -49,6 +49,8 @@ async def async_setup_entry(
|
|||||||
class TransmissionSensor(SensorEntity):
|
class TransmissionSensor(SensorEntity):
|
||||||
"""A base class for all Transmission sensors."""
|
"""A base class for all Transmission sensors."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, tm_client, client_name, sensor_name, sub_type=None):
|
def __init__(self, tm_client, client_name, sensor_name, sub_type=None):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self._tm_client: TransmissionClient = tm_client
|
self._tm_client: TransmissionClient = tm_client
|
||||||
@ -72,11 +74,6 @@ class TransmissionSensor(SensorEntity):
|
|||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Return the polling requirement for this sensor."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
"""Could the device be accessed during the last update call."""
|
"""Could the device be accessed during the last update call."""
|
||||||
|
@ -33,6 +33,8 @@ async def async_setup_entry(
|
|||||||
class TransmissionSwitch(SwitchEntity):
|
class TransmissionSwitch(SwitchEntity):
|
||||||
"""Representation of a Transmission switch."""
|
"""Representation of a Transmission switch."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, switch_type, switch_name, tm_client, name):
|
def __init__(self, switch_type, switch_name, tm_client, name):
|
||||||
"""Initialize the Transmission switch."""
|
"""Initialize the Transmission switch."""
|
||||||
self._name = switch_name
|
self._name = switch_name
|
||||||
@ -53,11 +55,6 @@ class TransmissionSwitch(SwitchEntity):
|
|||||||
"""Return the unique id of the entity."""
|
"""Return the unique id of the entity."""
|
||||||
return f"{self._tm_client.api.host}-{self.name}"
|
return f"{self._tm_client.api.host}-{self.name}"
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""Poll for status regularly."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if device is on."""
|
"""Return true if device is on."""
|
||||||
|
@ -112,6 +112,8 @@ def setup_platform(
|
|||||||
class SensorTrend(BinarySensorEntity):
|
class SensorTrend(BinarySensorEntity):
|
||||||
"""Representation of a trend Sensor."""
|
"""Representation of a trend Sensor."""
|
||||||
|
|
||||||
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass,
|
hass,
|
||||||
@ -167,11 +169,6 @@ class SensorTrend(BinarySensorEntity):
|
|||||||
ATTR_SAMPLE_DURATION: self._sample_duration,
|
ATTR_SAMPLE_DURATION: self._sample_duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
|
||||||
def should_poll(self):
|
|
||||||
"""No polling needed."""
|
|
||||||
return False
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Complete device setup after being added to hass."""
|
"""Complete device setup after being added to hass."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user