Default states-like UI if no Lovelace config
This commit is contained in:
parent
3dca28a7da
commit
dbeda6ea68
@ -128,14 +128,11 @@ class MobileAppIntegrationManager {
|
||||
popup: Popup(
|
||||
title: "App integration is not working properly",
|
||||
body: "Something wrong with HA Client integration on your Home Assistant server. Please report this issue. You can try to remove Mobile App integration from Home Assistant and restart server to fix this issue.",
|
||||
positiveText: "Report to GitHub",
|
||||
negativeText: "Report to Discord",
|
||||
positiveText: "Report issue",
|
||||
negativeText: "Close",
|
||||
onPositive: () {
|
||||
Launcher.launchURLInBrowser("https://github.com/estevez-dev/ha_client/issues/new");
|
||||
},
|
||||
onNegative: () {
|
||||
Launcher.launchURLInBrowser("https://discord.gg/u9vq7QE");
|
||||
},
|
||||
}
|
||||
)
|
||||
));
|
||||
}
|
||||
|
47
lib/ui.dart
47
lib/ui.dart
@ -30,8 +30,42 @@ class HomeAssistantUI {
|
||||
}
|
||||
|
||||
Map _generateLovelaceConfig() {
|
||||
Map result = {};
|
||||
result['title'] = 'Home';
|
||||
Map result = {
|
||||
'title': 'Home'
|
||||
};
|
||||
List<Entity> left = HomeAssistant().entities.getByDomains(
|
||||
excludeDomains: ['sensor','binary_sensor', 'device_tracker', 'person', 'sun']
|
||||
);
|
||||
List<Map> cards = [];
|
||||
Map<String, Map> cardsByDomains = {};
|
||||
left.forEach((Entity entity) {
|
||||
if (entity is GroupEntity) {
|
||||
cards.add({
|
||||
'type': CardType.ENTITIES,
|
||||
'title': entity.displayName,
|
||||
'entities': entity.childEntities.map((e) => e.entityId)
|
||||
});
|
||||
} else if (entity is MediaPlayerEntity) {
|
||||
cards.add({
|
||||
'type': CardType.MEDIA_CONTROL,
|
||||
'entity': entity.entityId
|
||||
});
|
||||
} else if (entity is AlarmControlPanelEntity) {
|
||||
cards.add({
|
||||
'type': CardType.ALARM_PANEL,
|
||||
'entity': entity.entityId
|
||||
});
|
||||
} else if (cardsByDomains.containsKey(entity.domain)) {
|
||||
cardsByDomains[entity.domain]['entities'].add(entity.entityId);
|
||||
} else {
|
||||
cardsByDomains[entity.domain] = {
|
||||
'type': 'entities',
|
||||
'entities': [entity.entityId],
|
||||
'title': entity.domain
|
||||
};
|
||||
}
|
||||
});
|
||||
cards.addAll(cardsByDomains.values);
|
||||
result['views'] = [
|
||||
{
|
||||
'icon': 'mdi:home',
|
||||
@ -40,14 +74,7 @@ class HomeAssistantUI {
|
||||
).map(
|
||||
(en) => en.entityId
|
||||
).toList(),
|
||||
'cards': [{
|
||||
'type': 'entities',
|
||||
'entities': HomeAssistant().entities.getByDomains(
|
||||
excludeDomains: ['sensor','binary_sensor', 'device_tracker', 'person', 'sun']
|
||||
).map(
|
||||
(en) => en.entityId
|
||||
).toList()
|
||||
}]
|
||||
'cards': cards
|
||||
}
|
||||
];
|
||||
return result;
|
||||
|
Reference in New Issue
Block a user