mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Directly call async_write_ha_state (#33508)
* Directly call async_write_ha_state * Address comments * Fix tests
This commit is contained in:
parent
4e043b3123
commit
aaa1d06809
@ -249,7 +249,7 @@ class Alert(ToggleEntity):
|
||||
else:
|
||||
await self._schedule_notify()
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def end_alerting(self):
|
||||
"""End the alert procedures."""
|
||||
@ -259,7 +259,7 @@ class Alert(ToggleEntity):
|
||||
self._firing = False
|
||||
if self._send_done_message:
|
||||
await self._notify_done_message()
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def _schedule_notify(self):
|
||||
"""Schedule a notification."""
|
||||
|
@ -67,7 +67,7 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
|
||||
else:
|
||||
await self._ipcam.change_setting(self._setting, True)
|
||||
self._state = True
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn device off."""
|
||||
@ -80,7 +80,7 @@ class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice):
|
||||
else:
|
||||
await self._ipcam.change_setting(self._setting, False)
|
||||
self._state = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
@ -138,7 +138,7 @@ class AppleTvDevice(MediaPlayerDevice):
|
||||
def playstatus_update(self, updater, playing):
|
||||
"""Print what is currently playing when it changes."""
|
||||
self._playing = playing
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def playstatus_error(self, updater, exception):
|
||||
@ -151,7 +151,7 @@ class AppleTvDevice(MediaPlayerDevice):
|
||||
# implemented here later.
|
||||
updater.start(initial_delay=10)
|
||||
self._playing = None
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def media_content_type(self):
|
||||
|
@ -109,4 +109,4 @@ class AquaLogicSensor(Entity):
|
||||
panel = self._processor.panel
|
||||
if panel is not None:
|
||||
self._state = getattr(panel, self._type)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -6,7 +6,6 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice
|
||||
from homeassistant.const import CONF_MONITORED_CONDITIONS
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from . import DOMAIN, UPDATE_TOPIC
|
||||
@ -51,7 +50,6 @@ class AquaLogicSwitch(SwitchDevice):
|
||||
|
||||
def __init__(self, processor, switch_type):
|
||||
"""Initialize switch."""
|
||||
|
||||
self._processor = processor
|
||||
self._type = switch_type
|
||||
self._state_name = {
|
||||
@ -66,6 +64,7 @@ class AquaLogicSwitch(SwitchDevice):
|
||||
"aux_6": States.AUX_6,
|
||||
"aux_7": States.AUX_7,
|
||||
}[switch_type]
|
||||
self._unsub_disp = None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@ -102,11 +101,11 @@ class AquaLogicSwitch(SwitchDevice):
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
self.hass.helpers.dispatcher.async_dispatcher_connect(
|
||||
UPDATE_TOPIC, self.async_update_callback
|
||||
self._unsub_disp = self.hass.helpers.dispatcher.async_dispatcher_connect(
|
||||
UPDATE_TOPIC, self.async_write_ha_state
|
||||
)
|
||||
|
||||
@callback
|
||||
def async_update_callback(self):
|
||||
"""Update callback."""
|
||||
self.async_schedule_update_ha_state()
|
||||
async def async_will_remove_from_hass(self):
|
||||
"""When entity will be removed from hass."""
|
||||
self._unsub_disp()
|
||||
self._unsub_disp = None
|
||||
|
@ -130,7 +130,7 @@ class ArcamFmj(MediaPlayerDevice):
|
||||
@callback
|
||||
def _data(host):
|
||||
if host == self._state.client.host:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def _started(host):
|
||||
@ -160,7 +160,7 @@ class ArcamFmj(MediaPlayerDevice):
|
||||
async def async_mute_volume(self, mute):
|
||||
"""Send mute command."""
|
||||
await self._state.set_mute(mute)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_select_source(self, source):
|
||||
"""Select a specific source."""
|
||||
@ -171,7 +171,7 @@ class ArcamFmj(MediaPlayerDevice):
|
||||
return
|
||||
|
||||
await self._state.set_source(value)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_select_sound_mode(self, sound_mode):
|
||||
"""Select a specific source."""
|
||||
@ -184,22 +184,22 @@ class ArcamFmj(MediaPlayerDevice):
|
||||
_LOGGER.error("Unsupported sound_mode %s", sound_mode)
|
||||
return
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_volume_level(self, volume):
|
||||
"""Set volume level, range 0..1."""
|
||||
await self._state.set_volume(round(volume * 99.0))
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_volume_up(self):
|
||||
"""Turn volume up for media player."""
|
||||
await self._state.inc_volume()
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_volume_down(self):
|
||||
"""Turn volume up for media player."""
|
||||
await self._state.dec_volume()
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self):
|
||||
"""Turn the media player on."""
|
||||
|
@ -7,7 +7,6 @@ import voluptuous as vol
|
||||
from homeassistant.components.camera import PLATFORM_SCHEMA, Camera
|
||||
from homeassistant.components.ffmpeg import DATA_FFMPEG
|
||||
from homeassistant.const import ATTR_BATTERY_LEVEL
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.aiohttp_client import async_aiohttp_proxy_stream
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
@ -62,6 +61,7 @@ class ArloCam(Camera):
|
||||
self._ffmpeg_arguments = device_info.get(CONF_FFMPEG_ARGUMENTS)
|
||||
self._last_refresh = None
|
||||
self.attrs = {}
|
||||
self._unsub_disp = None
|
||||
|
||||
def camera_image(self):
|
||||
"""Return a still image response from the camera."""
|
||||
@ -69,12 +69,14 @@ class ArloCam(Camera):
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
async_dispatcher_connect(self.hass, SIGNAL_UPDATE_ARLO, self._update_callback)
|
||||
self._unsub_disp = async_dispatcher_connect(
|
||||
self.hass, SIGNAL_UPDATE_ARLO, self.async_write_ha_state
|
||||
)
|
||||
|
||||
@callback
|
||||
def _update_callback(self):
|
||||
"""Call update method."""
|
||||
self.async_schedule_update_ha_state()
|
||||
async def async_will_remove_from_hass(self):
|
||||
"""When entity will be removed from hass."""
|
||||
self._unsub_disp()
|
||||
self._unsub_disp = None
|
||||
|
||||
async def handle_async_mjpeg_stream(self, request):
|
||||
"""Generate an HTTP MJPEG stream from the camera."""
|
||||
|
@ -119,7 +119,7 @@ class ArwnSensor(Entity):
|
||||
"""Update the sensor with the most recent event."""
|
||||
self.event = {}
|
||||
self.event.update(event)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
@ -41,7 +41,7 @@ class AxisEntityBase(Entity):
|
||||
@callback
|
||||
def update_callback(self, no_delay=None):
|
||||
"""Update the entities state."""
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class AxisEventBase(AxisEntityBase):
|
||||
|
@ -53,13 +53,13 @@ class AxisBinarySensor(AxisEventBase, BinarySensorDevice):
|
||||
self.remove_timer = None
|
||||
|
||||
if self.is_on or delay == 0 or no_delay:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
return
|
||||
|
||||
@callback
|
||||
def _delay_update(now):
|
||||
"""Timer callback for sensor update."""
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
self.remove_timer = None
|
||||
|
||||
self.remove_timer = async_track_point_in_utc_time(
|
||||
|
@ -426,7 +426,7 @@ class BluesoundPlayer(MediaPlayerDevice):
|
||||
# communication is moved to a separate library
|
||||
await self.force_update_sync_status()
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
elif response.status == 595:
|
||||
_LOGGER.info("Status 595 returned, treating as timeout")
|
||||
raise BluesoundPlayer._TimeoutException()
|
||||
@ -439,7 +439,7 @@ class BluesoundPlayer(MediaPlayerDevice):
|
||||
self._is_online = False
|
||||
self._last_status_update = None
|
||||
self._status = None
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
_LOGGER.info("Client connection error, marking %s as offline", self._name)
|
||||
raise
|
||||
|
||||
|
@ -356,7 +356,7 @@ class CastDevice(MediaPlayerDevice):
|
||||
self.cast_status = chromecast.status
|
||||
self.media_status = chromecast.media_controller.status
|
||||
self._chromecast.start()
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_del_cast_info(self, cast_info):
|
||||
"""Remove the service."""
|
||||
@ -411,7 +411,7 @@ class CastDevice(MediaPlayerDevice):
|
||||
self._dynamic_group_available = False
|
||||
self.dynamic_group_media_status = chromecast.media_controller.status
|
||||
self._dynamic_group_cast.start()
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_del_dynamic_group(self):
|
||||
"""Remove the dynamic group."""
|
||||
@ -432,7 +432,7 @@ class CastDevice(MediaPlayerDevice):
|
||||
|
||||
self._dynamic_group_invalidate()
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def _async_disconnect(self):
|
||||
"""Disconnect Chromecast object if it is set."""
|
||||
@ -447,7 +447,7 @@ class CastDevice(MediaPlayerDevice):
|
||||
self._cast_info.port,
|
||||
)
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
await self.hass.async_add_executor_job(self._chromecast.disconnect)
|
||||
if self._dynamic_group_cast is not None:
|
||||
@ -455,7 +455,7 @@ class CastDevice(MediaPlayerDevice):
|
||||
|
||||
self._invalidate()
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
def _invalidate(self):
|
||||
"""Invalidate some attributes."""
|
||||
|
@ -62,7 +62,7 @@ class CloudRemoteBinary(BinarySensorDevice):
|
||||
async def async_state_update(data):
|
||||
"""Update callback."""
|
||||
await asyncio.sleep(WAIT_UNTIL_CHANGE)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
self._unsub_dispatcher = async_dispatcher_connect(
|
||||
self.hass, DISPATCHER_REMOTE_UPDATE, async_state_update
|
||||
|
@ -64,7 +64,7 @@ class DeconzBinarySensor(DeconzDevice, BinarySensorDevice):
|
||||
|
||||
keys = {"on", "reachable", "state"}
|
||||
if force_update or self._device.changed_keys.intersection(keys):
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
@ -106,7 +106,7 @@ class DeconzDevice(DeconzBase, Entity):
|
||||
if ignore_update:
|
||||
return
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
|
@ -109,7 +109,7 @@ class DeconzSensor(DeconzDevice):
|
||||
|
||||
keys = {"on", "reachable", "state"}
|
||||
if force_update or self._device.changed_keys.intersection(keys):
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
@ -174,7 +174,7 @@ class DeconzBattery(DeconzDevice):
|
||||
|
||||
keys = {"battery", "reachable"}
|
||||
if force_update or self._device.changed_keys.intersection(keys):
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
@ -182,7 +182,7 @@ class DerivativeSensor(RestoreEntity):
|
||||
_LOGGER.error("Could not calculate derivative: %s", err)
|
||||
else:
|
||||
self._state = derivative
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async_track_state_change(self.hass, self._sensor_source_id, calc_derivative)
|
||||
|
||||
|
@ -48,7 +48,7 @@ class DSMRSensor(Entity):
|
||||
else:
|
||||
self._state = message.payload
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
await mqtt.async_subscribe(self.hass, self._topic, message_received, 1)
|
||||
|
||||
|
@ -166,7 +166,7 @@ class EmbyDevice(MediaPlayerDevice):
|
||||
self.media_status_last_position = None
|
||||
self.media_status_received = None
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
|
@ -121,7 +121,7 @@ class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanel):
|
||||
def _update_callback(self, partition):
|
||||
"""Update Home Assistant state, if needed."""
|
||||
if partition is None or int(partition) == self._partition_number:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def code_format(self):
|
||||
|
@ -94,4 +94,4 @@ class EnvisalinkBinarySensor(EnvisalinkDevice, BinarySensorDevice):
|
||||
def _update_callback(self, zone):
|
||||
"""Update the zone's state, if needed."""
|
||||
if zone is None or int(zone) == self._zone_number:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -74,4 +74,4 @@ class EnvisalinkSensor(EnvisalinkDevice, Entity):
|
||||
def _update_callback(self, partition):
|
||||
"""Update the partition state in HA, if needed."""
|
||||
if partition is None or int(partition) == self._partition_number:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -510,7 +510,7 @@ class EsphomeEntity(Entity):
|
||||
|
||||
async def _on_state_update(self) -> None:
|
||||
"""Update the entity state when state or static info changed."""
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def _on_device_update(self) -> None:
|
||||
"""Update the entity state when device info has changed."""
|
||||
@ -519,7 +519,7 @@ class EsphomeEntity(Entity):
|
||||
# Only update the HA state when the full state arrives
|
||||
# through the next entity state packet.
|
||||
return
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Unregister callbacks."""
|
||||
|
@ -202,6 +202,6 @@ class FFmpegBase(Entity):
|
||||
async def async_start_handle(event):
|
||||
"""Start FFmpeg process."""
|
||||
await self._async_start_ffmpeg(None)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, async_start_handle)
|
||||
|
@ -70,7 +70,7 @@ class FFmpegBinarySensor(FFmpegBase, BinarySensorDevice):
|
||||
def _async_callback(self, state):
|
||||
"""HA-FFmpeg callback for noise detection."""
|
||||
self._state = state
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
@ -212,7 +212,7 @@ class SensorFilter(Entity):
|
||||
)
|
||||
|
||||
if update_ha:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
if "recorder" in self.hass.config.components:
|
||||
history_list = []
|
||||
|
@ -233,7 +233,7 @@ class FluxSwitch(SwitchDevice, RestoreEntity):
|
||||
# Make initial update
|
||||
await self.async_flux_update()
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn off flux."""
|
||||
@ -241,7 +241,7 @@ class FluxSwitch(SwitchDevice, RestoreEntity):
|
||||
self.unsub_tracker()
|
||||
self.unsub_tracker = None
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_flux_update(self, utcnow=None):
|
||||
"""Update all the lights using flux."""
|
||||
|
@ -368,7 +368,7 @@ class GenericThermostat(ClimateDevice, RestoreEntity):
|
||||
"""Handle heater switch state changes."""
|
||||
if new_state is None:
|
||||
return
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def _async_update_temp(self, state):
|
||||
|
@ -129,7 +129,7 @@ class GEMSensor(Entity):
|
||||
async def async_will_remove_from_hass(self):
|
||||
"""Remove listener from the sensor."""
|
||||
if self._sensor:
|
||||
self._sensor.remove_listener(self._schedule_update)
|
||||
self._sensor.remove_listener(self.async_write_ha_state)
|
||||
else:
|
||||
monitors = self.hass.data[DATA_GREENEYE_MONITOR]
|
||||
monitors.remove_listener(self._on_new_monitor)
|
||||
@ -140,16 +140,13 @@ class GEMSensor(Entity):
|
||||
return False
|
||||
|
||||
self._sensor = self._get_sensor(monitor)
|
||||
self._sensor.add_listener(self._schedule_update)
|
||||
self._sensor.add_listener(self.async_write_ha_state)
|
||||
|
||||
return True
|
||||
|
||||
def _get_sensor(self, monitor):
|
||||
raise NotImplementedError()
|
||||
|
||||
def _schedule_update(self):
|
||||
self.async_schedule_update_ha_state(False)
|
||||
|
||||
|
||||
class CurrentSensor(GEMSensor):
|
||||
"""Entity showing power usage on one channel of the monitor."""
|
||||
|
@ -264,7 +264,7 @@ class HarmonyRemote(remote.RemoteDevice):
|
||||
self._current_activity = activity_name
|
||||
self._state = bool(activity_id != -1)
|
||||
self._available = True
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def new_config(self, _=None):
|
||||
"""Call for updating the current activity."""
|
||||
@ -289,7 +289,7 @@ class HarmonyRemote(remote.RemoteDevice):
|
||||
|
||||
if not self._available:
|
||||
# Still disconnected. Let the state engine know.
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
"""Start an activity from the Harmony device."""
|
||||
|
@ -12,7 +12,6 @@ from homeassistant.const import (
|
||||
CONF_SCAN_INTERVAL,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.discovery import load_platform
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
|
||||
@ -183,14 +182,17 @@ class HiveEntity(Entity):
|
||||
self.session = session
|
||||
self.attributes = {}
|
||||
self._unique_id = f"{self.node_id}-{self.device_type}"
|
||||
self._unsub_disp = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""When entity is added to Home Assistant."""
|
||||
async_dispatcher_connect(self.hass, DOMAIN, self._update_callback)
|
||||
self._unsub_disp = async_dispatcher_connect(
|
||||
self.hass, DOMAIN, self.async_write_ha_state
|
||||
)
|
||||
if self.device_type in SERVICES:
|
||||
self.session.entity_lookup[self.entity_id] = self.node_id
|
||||
|
||||
@callback
|
||||
def _update_callback(self):
|
||||
"""Call update method."""
|
||||
self.async_schedule_update_ha_state()
|
||||
async def async_will_remove_from_hass(self):
|
||||
"""When entity will be removed from hass."""
|
||||
self._unsub_disp()
|
||||
self._unsub_disp = None
|
||||
|
@ -136,7 +136,7 @@ class SW16Device(Entity):
|
||||
"""Propagate changes through ha."""
|
||||
_LOGGER.debug("Relay %s new state callback: %r", self._device_port, event)
|
||||
self._is_on = event
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
@ -156,7 +156,7 @@ class SW16Device(Entity):
|
||||
@callback
|
||||
def _availability_callback(self, availability):
|
||||
"""Update availability state."""
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register update callback."""
|
||||
|
@ -102,7 +102,7 @@ class HomematicipAlarmControlPanel(AlarmControlPanel):
|
||||
# Don't update disabled entities
|
||||
if self.enabled:
|
||||
_LOGGER.debug("Event %s (%s)", self.name, CONST_ALARM_CONTROL_PANEL_NAME)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
else:
|
||||
_LOGGER.debug(
|
||||
"Device Changed Event for %s (Alarm Control Panel) not fired. Entity is disabled.",
|
||||
|
@ -108,7 +108,7 @@ class HomematicipGenericDevice(Entity):
|
||||
# Don't update disabled entities
|
||||
if self.enabled:
|
||||
_LOGGER.debug("Event %s (%s)", self.name, self._device.modelType)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
else:
|
||||
_LOGGER.debug(
|
||||
"Device Changed Event for %s (%s) not fired. Entity is disabled.",
|
||||
|
@ -93,4 +93,4 @@ class HomeworksLight(HomeworksDevice, Light):
|
||||
self._level = int((values[1] * 255.0) / 100.0)
|
||||
if self._level != 0:
|
||||
self._prev_level = self._level
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -25,7 +25,6 @@ from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
@ -203,14 +202,18 @@ class AqualinkEntity(Entity):
|
||||
def __init__(self, dev: AqualinkDevice):
|
||||
"""Initialize the entity."""
|
||||
self.dev = dev
|
||||
self._unsub_disp = None
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Set up a listener when this entity is added to HA."""
|
||||
async_dispatcher_connect(self.hass, DOMAIN, self._update_callback)
|
||||
self._unsub_disp = async_dispatcher_connect(
|
||||
self.hass, DOMAIN, self.async_write_ha_state
|
||||
)
|
||||
|
||||
@callback
|
||||
def _update_callback(self) -> None:
|
||||
self.async_schedule_update_ha_state()
|
||||
async def async_will_remove_from_hass(self):
|
||||
"""When entity will be removed from hass."""
|
||||
self._unsub_disp()
|
||||
self._unsub_disp = None
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
|
@ -80,7 +80,7 @@ class InsteonEntity(Entity):
|
||||
group,
|
||||
val,
|
||||
)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register INSTEON update events."""
|
||||
|
@ -172,7 +172,7 @@ class IntegrationSensor(RestoreEntity):
|
||||
_LOGGER.error("Could not calculate integral: %s", err)
|
||||
else:
|
||||
self._state += integral
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async_track_state_change(self.hass, self._sensor_source_id, calc_integration)
|
||||
|
||||
|
@ -175,7 +175,7 @@ class ControllerDevice(ClimateDevice):
|
||||
"""Handle controller data updates."""
|
||||
if ctrl is not self._controller:
|
||||
return
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
for zone in self.zones.values():
|
||||
zone.async_schedule_update_ha_state()
|
||||
|
||||
@ -210,7 +210,7 @@ class ControllerDevice(ClimateDevice):
|
||||
)
|
||||
|
||||
self._available = available
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
for zone in self.zones.values():
|
||||
zone.async_schedule_update_ha_state()
|
||||
|
||||
@ -439,7 +439,7 @@ class ZoneDevice(ClimateDevice):
|
||||
if zone is not self._zone:
|
||||
return
|
||||
self._name = zone.name.title()
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(self.hass, DISPATCH_ZONE_UPDATE, zone_update)
|
||||
@ -549,7 +549,7 @@ class ZoneDevice(ClimateDevice):
|
||||
"""Set new target operation mode."""
|
||||
mode = self._state_to_pizone[hvac_mode]
|
||||
await self._controller.wrap_and_catch(self._zone.set_mode(mode))
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
@ -562,9 +562,9 @@ class ZoneDevice(ClimateDevice):
|
||||
await self._controller.wrap_and_catch(self._zone.set_mode(Zone.Mode.AUTO))
|
||||
else:
|
||||
await self._controller.wrap_and_catch(self._zone.set_mode(Zone.Mode.OPEN))
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self):
|
||||
"""Turn device off (close zone)."""
|
||||
await self._controller.wrap_and_catch(self._zone.set_mode(Zone.Mode.CLOSE))
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -94,7 +94,7 @@ class KiwiLock(LockDevice):
|
||||
def clear_unlock_state(self, _):
|
||||
"""Clear unlock state automatically."""
|
||||
self._state = STATE_LOCKED
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
def unlock(self, **kwargs):
|
||||
"""Unlock the device."""
|
||||
|
@ -204,7 +204,7 @@ class KNXCover(CoverDevice):
|
||||
@callback
|
||||
def auto_updater_hook(self, now):
|
||||
"""Call for the autoupdater."""
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
if self.device.position_reached():
|
||||
self.stop_auto_updater()
|
||||
|
||||
|
@ -364,14 +364,14 @@ class KodiDevice(MediaPlayerDevice):
|
||||
self._item = {}
|
||||
self._media_position_updated_at = None
|
||||
self._media_position = None
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def async_on_volume_changed(self, sender, data):
|
||||
"""Handle the volume changes."""
|
||||
self._app_properties["volume"] = data["volume"]
|
||||
self._app_properties["muted"] = data["muted"]
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def async_on_quit(self, sender, data):
|
||||
@ -429,7 +429,7 @@ class KodiDevice(MediaPlayerDevice):
|
||||
# to reconnect on the next poll.
|
||||
pass
|
||||
# Update HA state after Kodi disconnects
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
# Create a task instead of adding a tracking job, since this task will
|
||||
# run until the websocket connection is closed.
|
||||
|
@ -87,4 +87,4 @@ class KonnectedBinarySensor(BinarySensorDevice):
|
||||
def async_set_state(self, state):
|
||||
"""Update the sensor's state."""
|
||||
self._state = state
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -137,4 +137,4 @@ class KonnectedSensor(Entity):
|
||||
self._state = int(float(state))
|
||||
else:
|
||||
self._state = round(float(state), 1)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -117,7 +117,7 @@ class KonnectedSwitch(ToggleEntity):
|
||||
|
||||
def _set_state(self, state):
|
||||
self._state = state
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
_LOGGER.debug(
|
||||
"Setting status of %s actuator zone %s to %s",
|
||||
self._device_id,
|
||||
|
@ -171,7 +171,7 @@ class LaCrosseSensor(Entity):
|
||||
"""Triggered when value is expired."""
|
||||
self._expiration_trigger = None
|
||||
self._value = None
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class LaCrosseTemperature(LaCrosseSensor):
|
||||
|
@ -68,7 +68,7 @@ class LcnRegulatorLockSensor(LcnDevice, BinarySensorDevice):
|
||||
return
|
||||
|
||||
self._value = input_obj.get_value().is_locked_regulator()
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class LcnBinarySensor(LcnDevice, BinarySensorDevice):
|
||||
@ -100,7 +100,7 @@ class LcnBinarySensor(LcnDevice, BinarySensorDevice):
|
||||
return
|
||||
|
||||
self._value = input_obj.get_state(self.bin_sensor_port.value)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class LcnLockKeysSensor(LcnDevice, BinarySensorDevice):
|
||||
@ -135,4 +135,4 @@ class LcnLockKeysSensor(LcnDevice, BinarySensorDevice):
|
||||
key_id = int(self.source.name[1]) - 1
|
||||
|
||||
self._value = input_obj.get_state(table_id, key_id)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -125,7 +125,7 @@ class LcnClimate(LcnDevice, ClimateDevice):
|
||||
self.address_connection.lock_regulator(self.regulator_id, True)
|
||||
self._target_temperature = None
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_temperature(self, **kwargs):
|
||||
"""Set new target temperature."""
|
||||
@ -137,7 +137,7 @@ class LcnClimate(LcnDevice, ClimateDevice):
|
||||
self.address_connection.var_abs(
|
||||
self.setpoint, self._target_temperature, self.unit
|
||||
)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
def input_received(self, input_obj):
|
||||
"""Set temperature value when LCN input object is received."""
|
||||
@ -151,4 +151,4 @@ class LcnClimate(LcnDevice, ClimateDevice):
|
||||
if self._is_on:
|
||||
self._target_temperature = input_obj.get_value().to_var_unit(self.unit)
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -108,7 +108,7 @@ class LcnOutputsCover(LcnDevice, CoverDevice):
|
||||
elif self.state_down and not self.state_up:
|
||||
self._closed = True # Cover closed
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class LcnRelayCover(LcnDevice, CoverDevice):
|
||||
@ -167,4 +167,4 @@ class LcnRelayCover(LcnDevice, CoverDevice):
|
||||
if states[self.motor_port_onoff]: # motor is on
|
||||
self._closed = states[self.motor_port_updown] # set direction
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -132,7 +132,7 @@ class LcnOutputLight(LcnDevice, Light):
|
||||
self._is_dimming_to_zero = False
|
||||
if not self._is_dimming_to_zero:
|
||||
self._is_on = self.brightness > 0
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class LcnRelayLight(LcnDevice, Light):
|
||||
@ -182,4 +182,4 @@ class LcnRelayLight(LcnDevice, Light):
|
||||
return
|
||||
|
||||
self._is_on = input_obj.get_state(self.output.value)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -78,7 +78,7 @@ class LcnVariableSensor(LcnDevice):
|
||||
return
|
||||
|
||||
self._value = input_obj.get_value().to_var_unit(self.unit)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class LcnLedLogicSensor(LcnDevice):
|
||||
@ -115,4 +115,4 @@ class LcnLedLogicSensor(LcnDevice):
|
||||
elif self.source in pypck.lcn_defs.LogicOpPort:
|
||||
self._value = input_obj.get_logic_op_state(self.source.value).name.lower()
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -76,7 +76,7 @@ class LcnOutputSwitch(LcnDevice, SwitchDevice):
|
||||
return
|
||||
|
||||
self._is_on = input_obj.get_percent() > 0
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class LcnRelaySwitch(LcnDevice, SwitchDevice):
|
||||
@ -124,4 +124,4 @@ class LcnRelaySwitch(LcnDevice, SwitchDevice):
|
||||
return
|
||||
|
||||
self._is_on = input_obj.get_state(self.output.value)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -72,10 +72,10 @@ class LWRFLight(Light):
|
||||
else:
|
||||
self._lwlink.turn_on_light(self._device_id, self._name)
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn the LightWave light off."""
|
||||
self._state = False
|
||||
self._lwlink.turn_off(self._device_id, self._name)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -49,10 +49,10 @@ class LWRFSwitch(SwitchDevice):
|
||||
"""Turn the LightWave switch on."""
|
||||
self._state = True
|
||||
self._lwlink.turn_on_switch(self._device_id, self._name)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn the LightWave switch off."""
|
||||
self._state = False
|
||||
self._lwlink.turn_off(self._device_id, self._name)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -176,7 +176,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
self.set_state(stb_state)
|
||||
_LOGGER.debug("STB(%s) is [%s]", self.host, self._state)
|
||||
self._available = True
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async_dispatcher_connect(self.hass, SIGNAL_STB_NOTIFY, async_notify_received)
|
||||
|
||||
@ -200,7 +200,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
self._available = True
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
@ -242,7 +242,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
self._available = True
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self):
|
||||
"""Turn off the receiver."""
|
||||
@ -254,7 +254,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
self._available = True
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_media_play(self):
|
||||
"""Send play command."""
|
||||
@ -267,7 +267,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
self._available = True
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_media_pause(self):
|
||||
"""Send pause command."""
|
||||
@ -279,7 +279,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
self._available = True
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_media_stop(self):
|
||||
"""Send stop command."""
|
||||
@ -291,7 +291,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
self._available = True
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_media_previous_track(self):
|
||||
"""Send Program Down command."""
|
||||
@ -303,7 +303,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
self._available = True
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_media_next_track(self):
|
||||
"""Send Program Up command."""
|
||||
@ -315,7 +315,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
self._available = True
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_volume_up(self):
|
||||
"""Send volume up command."""
|
||||
@ -325,7 +325,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
self._available = True
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_volume_down(self):
|
||||
"""Send volume up command."""
|
||||
@ -334,7 +334,7 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
await self.stb.send_cmd("VolDown")
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_mute_volume(self, mute):
|
||||
"""Send mute command."""
|
||||
@ -343,4 +343,4 @@ class MediaroomDevice(MediaPlayerDevice):
|
||||
await self.stb.send_cmd("Mute")
|
||||
except PyMediaroomError:
|
||||
self._available = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -103,4 +103,4 @@ class MobileAppEntity(Entity):
|
||||
return
|
||||
|
||||
self._config = data
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -92,7 +92,7 @@ class MQTTRoomSensor(Entity):
|
||||
self._distance = distance
|
||||
self._updated = dt.utcnow()
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def message_received(msg):
|
||||
|
@ -73,7 +73,7 @@ class EVBinarySensor(BinarySensorDevice):
|
||||
"""Update state."""
|
||||
if self._car is not None:
|
||||
self._is_on = getattr(self._car, self._attr, None)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
@ -70,7 +70,7 @@ class MyChevyStatus(Entity):
|
||||
if self._state != MYCHEVY_SUCCESS:
|
||||
_LOGGER.debug("Successfully connected to mychevy website")
|
||||
self._state = MYCHEVY_SUCCESS
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def error(self):
|
||||
@ -80,7 +80,7 @@ class MyChevyStatus(Entity):
|
||||
"This probably means the mychevy to OnStar link is down"
|
||||
)
|
||||
self._state = MYCHEVY_ERROR
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
@ -156,7 +156,7 @@ class EVSensor(Entity):
|
||||
self._state = getattr(self._car, self._attr, None)
|
||||
for attr in self._extra_attrs:
|
||||
self._state_attributes[attr] = getattr(self._car, attr)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
@ -162,7 +162,7 @@ class MySensorsHVAC(mysensors.device.MySensorsEntity, ClimateDevice):
|
||||
if self.gateway.optimistic:
|
||||
# Optimistically assume that device has changed state
|
||||
self._values[value_type] = value
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_fan_mode(self, fan_mode):
|
||||
"""Set new target temperature."""
|
||||
@ -173,7 +173,7 @@ class MySensorsHVAC(mysensors.device.MySensorsEntity, ClimateDevice):
|
||||
if self.gateway.optimistic:
|
||||
# Optimistically assume that device has changed state
|
||||
self._values[set_req.V_HVAC_SPEED] = fan_mode
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode):
|
||||
"""Set new target temperature."""
|
||||
@ -187,7 +187,7 @@ class MySensorsHVAC(mysensors.device.MySensorsEntity, ClimateDevice):
|
||||
if self.gateway.optimistic:
|
||||
# Optimistically assume that device has changed state
|
||||
self._values[self.value_type] = hvac_mode
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_update(self):
|
||||
"""Update the controller with the latest value from a sensor."""
|
||||
|
@ -52,7 +52,7 @@ class MySensorsCover(mysensors.device.MySensorsEntity, CoverDevice):
|
||||
self._values[set_req.V_DIMMER] = 100
|
||||
else:
|
||||
self._values[set_req.V_LIGHT] = STATE_ON
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_close_cover(self, **kwargs):
|
||||
"""Move the cover down."""
|
||||
@ -66,7 +66,7 @@ class MySensorsCover(mysensors.device.MySensorsEntity, CoverDevice):
|
||||
self._values[set_req.V_DIMMER] = 0
|
||||
else:
|
||||
self._values[set_req.V_LIGHT] = STATE_OFF
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_cover_position(self, **kwargs):
|
||||
"""Move the cover to a specific position."""
|
||||
@ -78,7 +78,7 @@ class MySensorsCover(mysensors.device.MySensorsEntity, CoverDevice):
|
||||
if self.gateway.optimistic:
|
||||
# Optimistically assume that cover has changed state.
|
||||
self._values[set_req.V_DIMMER] = position
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_stop_cover(self, **kwargs):
|
||||
"""Stop the device."""
|
||||
|
@ -149,7 +149,7 @@ class MySensorsLight(mysensors.device.MySensorsEntity, Light):
|
||||
# optimistically assume that light has changed state
|
||||
self._state = False
|
||||
self._values[value_type] = STATE_OFF
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def _async_update_light(self):
|
||||
@ -189,7 +189,7 @@ class MySensorsLightDimmer(MySensorsLight):
|
||||
self._turn_on_light()
|
||||
self._turn_on_dimmer(**kwargs)
|
||||
if self.gateway.optimistic:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_update(self):
|
||||
"""Update the controller with the latest value from a sensor."""
|
||||
@ -215,7 +215,7 @@ class MySensorsLightRGB(MySensorsLight):
|
||||
self._turn_on_dimmer(**kwargs)
|
||||
self._turn_on_rgb_and_w("%02x%02x%02x", **kwargs)
|
||||
if self.gateway.optimistic:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_update(self):
|
||||
"""Update the controller with the latest value from a sensor."""
|
||||
@ -242,4 +242,4 @@ class MySensorsLightRGBW(MySensorsLightRGB):
|
||||
self._turn_on_dimmer(**kwargs)
|
||||
self._turn_on_rgb_and_w("%02x%02x%02x%02x", **kwargs)
|
||||
if self.gateway.optimistic:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -99,7 +99,7 @@ class MySensorsSwitch(mysensors.device.MySensorsEntity, SwitchDevice):
|
||||
if self.gateway.optimistic:
|
||||
# Optimistically assume that switch has changed state
|
||||
self._values[self.value_type] = STATE_ON
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn the switch off."""
|
||||
@ -109,7 +109,7 @@ class MySensorsSwitch(mysensors.device.MySensorsEntity, SwitchDevice):
|
||||
if self.gateway.optimistic:
|
||||
# Optimistically assume that switch has changed state
|
||||
self._values[self.value_type] = STATE_OFF
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class MySensorsIRSwitch(MySensorsSwitch):
|
||||
@ -141,7 +141,7 @@ class MySensorsIRSwitch(MySensorsSwitch):
|
||||
# Optimistically assume that switch has changed state
|
||||
self._values[self.value_type] = self._ir_code
|
||||
self._values[set_req.V_LIGHT] = STATE_ON
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
# Turn off switch after switch was turned on
|
||||
await self.async_turn_off()
|
||||
|
||||
@ -154,7 +154,7 @@ class MySensorsIRSwitch(MySensorsSwitch):
|
||||
if self.gateway.optimistic:
|
||||
# Optimistically assume that switch has changed state
|
||||
self._values[set_req.V_LIGHT] = STATE_OFF
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_update(self):
|
||||
"""Update the controller with the latest value from a sensor."""
|
||||
|
@ -86,4 +86,4 @@ class MyStromBinarySensor(BinarySensorDevice):
|
||||
def async_on_update(self, value):
|
||||
"""Receive an update."""
|
||||
self._state = value
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -111,4 +111,4 @@ class NessAlarmPanel(alarm.AlarmControlPanel):
|
||||
else:
|
||||
_LOGGER.warning("Unhandled arming state: %s", arming_state)
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -79,4 +79,4 @@ class NessZoneBinarySensor(BinarySensorDevice):
|
||||
"""Handle zone state update."""
|
||||
if self._zone_id == data.zone_id:
|
||||
self._state = data.state
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -69,7 +69,7 @@ class OpenThermBinarySensor(BinarySensorDevice):
|
||||
def receive_report(self, status):
|
||||
"""Handle status updates from the component."""
|
||||
self._state = bool(status.get(self._var))
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -80,7 +80,7 @@ class OpenThermClimate(ClimateDevice):
|
||||
"""Update climate entity options."""
|
||||
self.floor_temp = entry.options[CONF_FLOOR_TEMP]
|
||||
self.temp_precision = entry.options[CONF_PRECISION]
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Connect to the OpenTherm Gateway device."""
|
||||
@ -144,7 +144,7 @@ class OpenThermClimate(ClimateDevice):
|
||||
self._away_state_b = (
|
||||
status.get(gw_vars.OTGW_GPIO_B_STATE) == self._away_mode_b
|
||||
)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@ -253,7 +253,7 @@ class OpenThermClimate(ClimateDevice):
|
||||
self._new_target_temperature = await self._gateway.gateway.set_target_temp(
|
||||
temp
|
||||
)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
|
@ -73,7 +73,7 @@ class OpenThermSensor(Entity):
|
||||
if isinstance(value, float):
|
||||
value = f"{value:2.1f}"
|
||||
self._value = value
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -54,7 +54,7 @@ class TOTPSensor(Entity):
|
||||
@callback
|
||||
def _call_loop(self):
|
||||
self._state = self._otp.now()
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
# Update must occur at even TIME_STEP, e.g. 12:00:00, 12:00:30,
|
||||
# 12:01:00, etc. in order to have synced time (see RFC6238)
|
||||
|
@ -484,7 +484,7 @@ class Person(RestoreEntity):
|
||||
self._longitude = None
|
||||
self._gps_accuracy = None
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def _parse_source_state(self, state):
|
||||
|
@ -255,7 +255,7 @@ class Plant(Entity):
|
||||
self._state = STATE_OK
|
||||
self._problems = PROBLEM_NONE
|
||||
_LOGGER.debug("New data processed")
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
def _check_min(self, sensor_name, value, params):
|
||||
"""If configured, check the value against the defined minimum value."""
|
||||
@ -322,7 +322,7 @@ class Plant(Entity):
|
||||
except ValueError:
|
||||
pass
|
||||
_LOGGER.debug("Initializing from database completed")
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
@ -72,7 +72,7 @@ class MinutPointAlarmControl(AlarmControlPanel):
|
||||
_LOGGER.debug("Received webhook: %s", _type)
|
||||
self._home["alarm_status"] = _type
|
||||
self._changed_by = _changed_by
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def _home(self):
|
||||
|
@ -95,7 +95,7 @@ class MinutPointBinarySensor(MinutPointEntity, BinarySensorDevice):
|
||||
self._is_on = True
|
||||
else:
|
||||
self._is_on = None
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def _webhook_event(self, data, webhook):
|
||||
@ -111,7 +111,7 @@ class MinutPointBinarySensor(MinutPointEntity, BinarySensorDevice):
|
||||
self._is_on = True
|
||||
if _type == self._events[1]:
|
||||
self._is_on = None
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
@ -62,7 +62,7 @@ class MinutPointSensor(MinutPointEntity):
|
||||
self.device.sensor, self.device_class
|
||||
)
|
||||
self._updated = parse_datetime(self.device.last_update)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
@ -144,7 +144,7 @@ class PushCamera(Camera):
|
||||
self._state = STATE_IDLE
|
||||
self._expired_listener = None
|
||||
_LOGGER.debug("Reset state")
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
if self._expired_listener:
|
||||
self._expired_listener()
|
||||
@ -153,7 +153,7 @@ class PushCamera(Camera):
|
||||
self.hass, reset_state, dt_util.utcnow() + self._timeout
|
||||
)
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_camera_image(self):
|
||||
"""Return a still image response."""
|
||||
|
@ -87,7 +87,7 @@ class QSEntity(Entity):
|
||||
@callback
|
||||
def update_packet(self, packet):
|
||||
"""Receive update packet from QSUSB. Match dispather_send signature."""
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Listen for updates from QSUSb via dispatcher."""
|
||||
|
@ -52,7 +52,7 @@ class QSBinarySensor(QSEntity, BinarySensorDevice):
|
||||
)
|
||||
if val is not None:
|
||||
self._val = bool(val)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
@ -51,7 +51,7 @@ class QSSensor(QSEntity):
|
||||
)
|
||||
if val is not None:
|
||||
self._val = val
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
@ -313,7 +313,7 @@ class RflinkDevice(Entity):
|
||||
self._handle_event(event)
|
||||
|
||||
# Propagate changes through ha
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
# Put command onto bus for user to subscribe to
|
||||
if self._should_fire_event and identify_event_type(event) == EVENT_KEY_COMMAND:
|
||||
@ -360,7 +360,7 @@ class RflinkDevice(Entity):
|
||||
def _availability_callback(self, availability):
|
||||
"""Update availability state."""
|
||||
self._available = availability
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register update callback."""
|
||||
|
@ -84,7 +84,7 @@ class RflinkBinarySensor(RflinkDevice, BinarySensorDevice):
|
||||
"""Switch device off after a delay."""
|
||||
self._delay_listener = None
|
||||
self._state = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
if self._delay_listener is not None:
|
||||
self._delay_listener()
|
||||
|
@ -82,7 +82,7 @@ class RingLight(RingEntityMixin, Light):
|
||||
|
||||
self._light_on = new_state == ON_STATE
|
||||
self._no_updates_until = dt_util.utcnow() + SKIP_UPDATES_DELAY
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the light on for 30 seconds."""
|
||||
|
@ -78,7 +78,7 @@ class SatelIntegraAlarmPanel(alarm.AlarmControlPanel):
|
||||
_LOGGER.debug("Got status update, current status: %s", state)
|
||||
if state != self._state:
|
||||
self._state = state
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
else:
|
||||
_LOGGER.debug("Ignoring alarm status message, same state")
|
||||
|
||||
|
@ -110,4 +110,4 @@ class SatelIntegraBinarySensor(BinarySensorDevice):
|
||||
"""Update the zone's state, if needed."""
|
||||
if self._device_number in zones and self._state != zones[self._device_number]:
|
||||
self._state = zones[self._device_number]
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -65,13 +65,13 @@ class SatelIntegraSwitch(SwitchDevice):
|
||||
_LOGGER.debug("New state: %s", new_state)
|
||||
if new_state != self._state:
|
||||
self._state = new_state
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
"""Turn the device on."""
|
||||
_LOGGER.debug("Switch: %s status: %s, turning on", self._name, self._state)
|
||||
await self._satel.set_output(self._code, self._device_number, True)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn the device off."""
|
||||
@ -79,7 +79,7 @@ class SatelIntegraSwitch(SwitchDevice):
|
||||
"Switch name: %s status: %s, turning off", self._name, self._state
|
||||
)
|
||||
await self._satel.set_output(self._code, self._device_number, False)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
@ -84,7 +84,7 @@ class SerialSensor(Entity):
|
||||
|
||||
_LOGGER.debug("Received: %s", line)
|
||||
self._state = line
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def stop_serial_read(self):
|
||||
"""Close resources."""
|
||||
|
@ -36,7 +36,7 @@ class SisyphusLight(Light):
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Add listeners after this object has been initialized."""
|
||||
self._table.add_listener(lambda: self.async_schedule_update_ha_state(False))
|
||||
self._table.add_listener(self.async_write_ha_state)
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
|
@ -67,7 +67,7 @@ class SisyphusPlayer(MediaPlayerDevice):
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Add listeners after this object has been initialized."""
|
||||
self._table.add_listener(lambda: self.async_schedule_update_ha_state(False))
|
||||
self._table.add_listener(self.async_write_ha_state)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
@ -336,7 +336,7 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateDevice):
|
||||
await self._device.set_fan_mode(fan_mode, set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode):
|
||||
"""Set new target operation mode."""
|
||||
@ -355,7 +355,7 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateDevice):
|
||||
await asyncio.gather(*tasks)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_temperature(self, **kwargs):
|
||||
"""Set new target temperature."""
|
||||
@ -376,21 +376,21 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateDevice):
|
||||
await asyncio.gather(*tasks)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self):
|
||||
"""Turn device on."""
|
||||
await self._device.switch_on(set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self):
|
||||
"""Turn device off."""
|
||||
await self._device.switch_off(set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_update(self):
|
||||
"""Update the calculated fields of the AC."""
|
||||
|
@ -48,7 +48,7 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
||||
await self._device.set_fan_speed(value, set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self, speed: str = None, **kwargs) -> None:
|
||||
"""Turn the fan on."""
|
||||
@ -59,14 +59,14 @@ class SmartThingsFan(SmartThingsEntity, FanEntity):
|
||||
await self._device.switch_on(set_status=True)
|
||||
# State is set optimistically in the commands above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
"""Turn the fan off."""
|
||||
await self._device.switch_off(set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
@ -44,12 +44,12 @@ class SmartThingsLock(SmartThingsEntity, LockDevice):
|
||||
async def async_lock(self, **kwargs):
|
||||
"""Lock the device."""
|
||||
await self._device.lock(set_status=True)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_unlock(self, **kwargs):
|
||||
"""Unlock the device."""
|
||||
await self._device.unlock(set_status=True)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_locked(self):
|
||||
|
@ -37,14 +37,14 @@ class SmartThingsSwitch(SmartThingsEntity, SwitchDevice):
|
||||
await self._device.switch_off(set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self, **kwargs) -> None:
|
||||
"""Turn the switch on."""
|
||||
await self._device.switch_on(set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def current_power_w(self):
|
||||
|
@ -176,17 +176,17 @@ class SnapcastGroupDevice(MediaPlayerDevice):
|
||||
streams = self._group.streams_by_name()
|
||||
if source in streams:
|
||||
await self._group.set_stream(streams[source].identifier)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_mute_volume(self, mute):
|
||||
"""Send the mute command."""
|
||||
await self._group.set_muted(mute)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_volume_level(self, volume):
|
||||
"""Set the volume level."""
|
||||
await self._group.set_volume(round(volume * 100))
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
def snapshot(self):
|
||||
"""Snapshot the group state."""
|
||||
@ -273,17 +273,17 @@ class SnapcastClientDevice(MediaPlayerDevice):
|
||||
streams = self._client.group.streams_by_name()
|
||||
if source in streams:
|
||||
await self._client.group.set_stream(streams[source].identifier)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_mute_volume(self, mute):
|
||||
"""Send the mute command."""
|
||||
await self._client.set_muted(mute)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_volume_level(self, volume):
|
||||
"""Set the volume level."""
|
||||
await self._client.set_volume(round(volume * 100))
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_join(self, master):
|
||||
"""Join the group of the master player."""
|
||||
@ -293,12 +293,12 @@ class SnapcastClientDevice(MediaPlayerDevice):
|
||||
if master.identifier in group.clients
|
||||
]
|
||||
await master_group[0].add_client(self._client.identifier)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_unjoin(self):
|
||||
"""Unjoin the group the player is currently in."""
|
||||
await self._client.group.remove_client(self._client.identifier)
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
def snapshot(self):
|
||||
"""Snapshot the client state."""
|
||||
|
@ -464,7 +464,7 @@ class SonosEntity(MediaPlayerDevice):
|
||||
self._seen_timer()
|
||||
self.async_unseen()
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@callback
|
||||
def async_unseen(self, now=None):
|
||||
@ -483,7 +483,7 @@ class SonosEntity(MediaPlayerDevice):
|
||||
|
||||
self._subscriptions = []
|
||||
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
@ -725,7 +725,7 @@ class SonosEntity(MediaPlayerDevice):
|
||||
|
||||
self._coordinator = None
|
||||
self._sonos_group = sonos_group
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
for slave_uid in group[1:]:
|
||||
slave = _get_entity_from_soco_uid(self.hass, slave_uid)
|
||||
|
@ -121,7 +121,7 @@ class SwitcherControl(SwitchDevice):
|
||||
else:
|
||||
self._device_data = device_data
|
||||
self._state = self._device_data.state
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self, **kwargs: Dict) -> None:
|
||||
"""Turn the entity on."""
|
||||
@ -149,4 +149,4 @@ class SwitcherControl(SwitchDevice):
|
||||
if response and response.successful:
|
||||
self._self_initiated = True
|
||||
self._state = SWITCHER_STATE_ON if send_on else SWITCHER_STATE_OFF
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
@ -43,7 +43,7 @@ class TelldusLiveEntity(Entity):
|
||||
"""Return the property of the device might have changed."""
|
||||
if self.device.name:
|
||||
self._name = self.device.name
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def device_id(self):
|
||||
|
@ -236,7 +236,7 @@ class AlarmControlPanelTemplate(AlarmControlPanel):
|
||||
_LOGGER.error("No script action defined for %s", state)
|
||||
|
||||
if optimistic_set:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_alarm_arm_away(self, code=None):
|
||||
"""Arm the panel to Away."""
|
||||
|
@ -283,7 +283,7 @@ class BinarySensorTemplate(BinarySensorDevice):
|
||||
def set_state():
|
||||
"""Set state of template binary sensor."""
|
||||
self._state = state
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
# state without delay
|
||||
if (state and not self._delay_on) or (not state and not self._delay_off):
|
||||
|
@ -322,7 +322,7 @@ class CoverTemplate(CoverDevice):
|
||||
)
|
||||
if self._optimistic:
|
||||
self._position = 100
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_close_cover(self, **kwargs):
|
||||
"""Move the cover down."""
|
||||
@ -334,7 +334,7 @@ class CoverTemplate(CoverDevice):
|
||||
)
|
||||
if self._optimistic:
|
||||
self._position = 0
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_stop_cover(self, **kwargs):
|
||||
"""Fire the stop action."""
|
||||
@ -348,7 +348,7 @@ class CoverTemplate(CoverDevice):
|
||||
{"position": self._position}, context=self._context
|
||||
)
|
||||
if self._optimistic:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_open_cover_tilt(self, **kwargs):
|
||||
"""Tilt the cover open."""
|
||||
@ -357,7 +357,7 @@ class CoverTemplate(CoverDevice):
|
||||
{"tilt": self._tilt_value}, context=self._context
|
||||
)
|
||||
if self._tilt_optimistic:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_close_cover_tilt(self, **kwargs):
|
||||
"""Tilt the cover closed."""
|
||||
@ -366,7 +366,7 @@ class CoverTemplate(CoverDevice):
|
||||
{"tilt": self._tilt_value}, context=self._context
|
||||
)
|
||||
if self._tilt_optimistic:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_cover_tilt_position(self, **kwargs):
|
||||
"""Move the cover tilt to a specific position."""
|
||||
@ -375,7 +375,7 @@ class CoverTemplate(CoverDevice):
|
||||
{"tilt": self._tilt_value}, context=self._context
|
||||
)
|
||||
if self._tilt_optimistic:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_update(self):
|
||||
"""Update the state from the template."""
|
||||
|
@ -316,14 +316,14 @@ class LightTemplate(Light):
|
||||
await self._on_script.async_run()
|
||||
|
||||
if optimistic_set:
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn the light off."""
|
||||
await self._off_script.async_run(context=self._context)
|
||||
if self._template is None:
|
||||
self._state = False
|
||||
self.async_schedule_update_ha_state()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_update(self):
|
||||
"""Update from templates."""
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user