mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Remove mysensors assumed state dead code (#140227)
This commit is contained in:
parent
f3a43e273a
commit
8b4d9f96d4
@ -175,10 +175,6 @@ class MySensorsHVAC(MySensorsChildEntity, ClimateEntity):
|
|||||||
self.gateway.set_child_value(
|
self.gateway.set_child_value(
|
||||||
self.node_id, self.child_id, value_type, value, ack=1
|
self.node_id, self.child_id, value_type, value, ack=1
|
||||||
)
|
)
|
||||||
if self.assumed_state:
|
|
||||||
# Optimistically assume that device has changed state
|
|
||||||
self._values[value_type] = value
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
@ -186,10 +182,6 @@ class MySensorsHVAC(MySensorsChildEntity, ClimateEntity):
|
|||||||
self.gateway.set_child_value(
|
self.gateway.set_child_value(
|
||||||
self.node_id, self.child_id, set_req.V_HVAC_SPEED, fan_mode, ack=1
|
self.node_id, self.child_id, set_req.V_HVAC_SPEED, fan_mode, ack=1
|
||||||
)
|
)
|
||||||
if self.assumed_state:
|
|
||||||
# Optimistically assume that device has changed state
|
|
||||||
self._values[set_req.V_HVAC_SPEED] = fan_mode
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
@ -200,10 +192,6 @@ class MySensorsHVAC(MySensorsChildEntity, ClimateEntity):
|
|||||||
DICT_HA_TO_MYS[hvac_mode],
|
DICT_HA_TO_MYS[hvac_mode],
|
||||||
ack=1,
|
ack=1,
|
||||||
)
|
)
|
||||||
if self.assumed_state:
|
|
||||||
# Optimistically assume that device has changed state
|
|
||||||
self._values[self.value_type] = hvac_mode
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_update(self) -> None:
|
def _async_update(self) -> None:
|
||||||
|
@ -7,7 +7,7 @@ from typing import Any
|
|||||||
|
|
||||||
from homeassistant.components.cover import ATTR_POSITION, CoverEntity
|
from homeassistant.components.cover import ATTR_POSITION, CoverEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON, Platform
|
from homeassistant.const import STATE_ON, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
@ -110,13 +110,6 @@ class MySensorsCover(MySensorsChildEntity, CoverEntity):
|
|||||||
self.gateway.set_child_value(
|
self.gateway.set_child_value(
|
||||||
self.node_id, self.child_id, set_req.V_UP, 1, ack=1
|
self.node_id, self.child_id, set_req.V_UP, 1, ack=1
|
||||||
)
|
)
|
||||||
if self.assumed_state:
|
|
||||||
# Optimistically assume that cover has changed state.
|
|
||||||
if set_req.V_DIMMER in self._values:
|
|
||||||
self._values[set_req.V_DIMMER] = 100
|
|
||||||
else:
|
|
||||||
self._values[set_req.V_LIGHT] = STATE_ON
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||||
"""Move the cover down."""
|
"""Move the cover down."""
|
||||||
@ -124,13 +117,6 @@ class MySensorsCover(MySensorsChildEntity, CoverEntity):
|
|||||||
self.gateway.set_child_value(
|
self.gateway.set_child_value(
|
||||||
self.node_id, self.child_id, set_req.V_DOWN, 1, ack=1
|
self.node_id, self.child_id, set_req.V_DOWN, 1, ack=1
|
||||||
)
|
)
|
||||||
if self.assumed_state:
|
|
||||||
# Optimistically assume that cover has changed state.
|
|
||||||
if set_req.V_DIMMER in self._values:
|
|
||||||
self._values[set_req.V_DIMMER] = 0
|
|
||||||
else:
|
|
||||||
self._values[set_req.V_LIGHT] = STATE_OFF
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||||
"""Move the cover to a specific position."""
|
"""Move the cover to a specific position."""
|
||||||
@ -139,10 +125,6 @@ class MySensorsCover(MySensorsChildEntity, CoverEntity):
|
|||||||
self.gateway.set_child_value(
|
self.gateway.set_child_value(
|
||||||
self.node_id, self.child_id, set_req.V_DIMMER, position, ack=1
|
self.node_id, self.child_id, set_req.V_DIMMER, position, ack=1
|
||||||
)
|
)
|
||||||
if self.assumed_state:
|
|
||||||
# Optimistically assume that cover has changed state.
|
|
||||||
self._values[set_req.V_DIMMER] = position
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||||
"""Stop the device."""
|
"""Stop the device."""
|
||||||
|
@ -12,7 +12,7 @@ from homeassistant.components.light import (
|
|||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON, Platform
|
from homeassistant.const import STATE_ON, Platform
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
@ -77,11 +77,6 @@ class MySensorsLight(MySensorsChildEntity, LightEntity):
|
|||||||
self.node_id, self.child_id, set_req.V_LIGHT, 1, ack=1
|
self.node_id, self.child_id, set_req.V_LIGHT, 1, ack=1
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.assumed_state:
|
|
||||||
# optimistically assume that light has changed state
|
|
||||||
self._state = True
|
|
||||||
self._values[set_req.V_LIGHT] = STATE_ON
|
|
||||||
|
|
||||||
def _turn_on_dimmer(self, **kwargs: Any) -> None:
|
def _turn_on_dimmer(self, **kwargs: Any) -> None:
|
||||||
"""Turn on dimmer child device."""
|
"""Turn on dimmer child device."""
|
||||||
set_req = self.gateway.const.SetReq
|
set_req = self.gateway.const.SetReq
|
||||||
@ -98,20 +93,10 @@ class MySensorsLight(MySensorsChildEntity, LightEntity):
|
|||||||
self.node_id, self.child_id, set_req.V_DIMMER, percent, ack=1
|
self.node_id, self.child_id, set_req.V_DIMMER, percent, ack=1
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.assumed_state:
|
|
||||||
# optimistically assume that light has changed state
|
|
||||||
self._attr_brightness = brightness
|
|
||||||
self._values[set_req.V_DIMMER] = percent
|
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
value_type = self.gateway.const.SetReq.V_LIGHT
|
value_type = self.gateway.const.SetReq.V_LIGHT
|
||||||
self.gateway.set_child_value(self.node_id, self.child_id, value_type, 0, ack=1)
|
self.gateway.set_child_value(self.node_id, self.child_id, value_type, 0, ack=1)
|
||||||
if self.assumed_state:
|
|
||||||
# optimistically assume that light has changed state
|
|
||||||
self._state = False
|
|
||||||
self._values[value_type] = STATE_OFF
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_update_light(self) -> None:
|
def _async_update_light(self) -> None:
|
||||||
@ -139,8 +124,6 @@ class MySensorsLightDimmer(MySensorsLight):
|
|||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
self._turn_on_light()
|
self._turn_on_light()
|
||||||
self._turn_on_dimmer(**kwargs)
|
self._turn_on_dimmer(**kwargs)
|
||||||
if self.assumed_state:
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_update(self) -> None:
|
def _async_update(self) -> None:
|
||||||
@ -161,8 +144,6 @@ class MySensorsLightRGB(MySensorsLight):
|
|||||||
self._turn_on_light()
|
self._turn_on_light()
|
||||||
self._turn_on_dimmer(**kwargs)
|
self._turn_on_dimmer(**kwargs)
|
||||||
self._turn_on_rgb(**kwargs)
|
self._turn_on_rgb(**kwargs)
|
||||||
if self.assumed_state:
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
def _turn_on_rgb(self, **kwargs: Any) -> None:
|
def _turn_on_rgb(self, **kwargs: Any) -> None:
|
||||||
"""Turn on RGB child device."""
|
"""Turn on RGB child device."""
|
||||||
@ -176,11 +157,6 @@ class MySensorsLightRGB(MySensorsLight):
|
|||||||
self.node_id, self.child_id, self.value_type, hex_color, ack=1
|
self.node_id, self.child_id, self.value_type, hex_color, ack=1
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.assumed_state:
|
|
||||||
# optimistically assume that light has changed state
|
|
||||||
self._attr_rgb_color = new_rgb
|
|
||||||
self._values[self.value_type] = hex_color
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_update(self) -> None:
|
def _async_update(self) -> None:
|
||||||
"""Update the controller with the latest value from a sensor."""
|
"""Update the controller with the latest value from a sensor."""
|
||||||
@ -209,8 +185,6 @@ class MySensorsLightRGBW(MySensorsLightRGB):
|
|||||||
self._turn_on_light()
|
self._turn_on_light()
|
||||||
self._turn_on_dimmer(**kwargs)
|
self._turn_on_dimmer(**kwargs)
|
||||||
self._turn_on_rgbw(**kwargs)
|
self._turn_on_rgbw(**kwargs)
|
||||||
if self.assumed_state:
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
def _turn_on_rgbw(self, **kwargs: Any) -> None:
|
def _turn_on_rgbw(self, **kwargs: Any) -> None:
|
||||||
"""Turn on RGBW child device."""
|
"""Turn on RGBW child device."""
|
||||||
@ -224,11 +198,6 @@ class MySensorsLightRGBW(MySensorsLightRGB):
|
|||||||
self.node_id, self.child_id, self.value_type, hex_color, ack=1
|
self.node_id, self.child_id, self.value_type, hex_color, ack=1
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.assumed_state:
|
|
||||||
# optimistically assume that light has changed state
|
|
||||||
self._attr_rgbw_color = new_rgbw
|
|
||||||
self._values[self.value_type] = hex_color
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_update_rgb_or_w(self) -> None:
|
def _async_update_rgb_or_w(self) -> None:
|
||||||
"""Update the controller with values from RGBW child."""
|
"""Update the controller with values from RGBW child."""
|
||||||
|
@ -6,7 +6,7 @@ from typing import Any
|
|||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON, Platform
|
from homeassistant.const import STATE_ON, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
@ -69,17 +69,9 @@ class MySensorsSwitch(MySensorsChildEntity, SwitchEntity):
|
|||||||
self.gateway.set_child_value(
|
self.gateway.set_child_value(
|
||||||
self.node_id, self.child_id, self.value_type, 1, ack=1
|
self.node_id, self.child_id, self.value_type, 1, ack=1
|
||||||
)
|
)
|
||||||
if self.assumed_state:
|
|
||||||
# Optimistically assume that switch has changed state
|
|
||||||
self._values[self.value_type] = STATE_ON
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch off."""
|
"""Turn the switch off."""
|
||||||
self.gateway.set_child_value(
|
self.gateway.set_child_value(
|
||||||
self.node_id, self.child_id, self.value_type, 0, ack=1
|
self.node_id, self.child_id, self.value_type, 0, ack=1
|
||||||
)
|
)
|
||||||
if self.assumed_state:
|
|
||||||
# Optimistically assume that switch has changed state
|
|
||||||
self._values[self.value_type] = STATE_OFF
|
|
||||||
self.async_write_ha_state()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user