Resolves #526 Subscribe to Lovelace update events

This commit is contained in:
Yegor Vialov
2020-03-19 23:16:59 +00:00
parent a3548455eb
commit 5ced01463f
3 changed files with 26 additions and 1 deletions

View File

@ -49,6 +49,7 @@ class HomeAssistant {
HomeAssistant._internal() {
ConnectionManager().onStateChangeCallback = _handleEntityStateChange;
ConnectionManager().onLovelaceUpdatedCallback = _handleLovelaceUpdate;
DeviceInfoManager().loadDeviceInfo();
}
@ -296,6 +297,14 @@ class HomeAssistant {
return completer.future;
}
void _handleLovelaceUpdate() {
if (_fetchCompleter != null && _fetchCompleter.isCompleted) {
eventBus.fire(new StateChangedEvent(
needToRebuildUI: true
));
}
}
void _handleEntityStateChange(Map eventData) {
//TheLogger.debug( "New state for ${eventData['entity_id']}");
if (_fetchCompleter != null && _fetchCompleter.isCompleted) {