mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Revert DSMR not calling entity methods (#36179)
This commit is contained in:
parent
cb2821b512
commit
cfaa851b5b
@ -17,10 +17,6 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import CoreState, callback
|
from homeassistant.core import CoreState, callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import (
|
|
||||||
async_dispatcher_connect,
|
|
||||||
async_dispatcher_send,
|
|
||||||
)
|
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -113,7 +109,11 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
|
|
||||||
async_add_entities(devices)
|
async_add_entities(devices)
|
||||||
|
|
||||||
update_entities_telegram = partial(async_dispatcher_send, hass, DOMAIN)
|
def update_entities_telegram(telegram):
|
||||||
|
"""Update entities with latest telegram and trigger state update."""
|
||||||
|
# Make all device entities aware of new telegram
|
||||||
|
for device in devices:
|
||||||
|
device.update_data(telegram)
|
||||||
|
|
||||||
# Creates an asyncio.Protocol factory for reading DSMR telegrams from
|
# Creates an asyncio.Protocol factory for reading DSMR telegrams from
|
||||||
# serial and calls update_entities_telegram to update entities on arrival
|
# serial and calls update_entities_telegram to update entities on arrival
|
||||||
@ -187,17 +187,12 @@ class DSMREntity(Entity):
|
|||||||
self._config = config
|
self._config = config
|
||||||
self.telegram = {}
|
self.telegram = {}
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
|
||||||
"""When entity is added to hass."""
|
|
||||||
self.async_on_remove(
|
|
||||||
async_dispatcher_connect(self.hass, DOMAIN, self.update_data)
|
|
||||||
)
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def update_data(self, telegram):
|
def update_data(self, telegram):
|
||||||
"""Update data."""
|
"""Update data."""
|
||||||
self.telegram = telegram
|
self.telegram = telegram
|
||||||
self.async_write_ha_state()
|
if self.hass:
|
||||||
|
self.async_write_ha_state()
|
||||||
|
|
||||||
def get_dsmr_object_attr(self, attribute):
|
def get_dsmr_object_attr(self, attribute):
|
||||||
"""Read attribute from last received telegram for this DSMR object."""
|
"""Read attribute from last received telegram for this DSMR object."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user