Created
November 30, 2019 23:31
-
-
Save zachowj/141af91e0c7472e207c22f0b0430c3f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@callback | |
def handle_discovery_update(self, msg): | |
"""Update entity config""" | |
if CONF_REMOVE in msg: | |
# Remove entity | |
if msg[CONF_REMOVE] == CHANGE_ENTITY_TYPE: | |
# recreate entity if component type changed | |
@callback | |
def recreate_entity(): | |
"""Create entity with new type""" | |
del msg[CONF_REMOVE] | |
async_dispatcher_send( | |
self.hass, NODERED_DISCOVERY.format(msg[CONF_COMPONENT]), msg | |
) | |
self.async_on_remove(recreate_entity) | |
self.hass.async_create_task(self.async_remove()) | |
else: | |
self._config = msg[CONF_CONFIG] | |
self.async_write_ha_state() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment