Resolves #205, Resolves #417 Condotional cards support

This commit is contained in:
estevez-dev
2019-08-26 17:03:28 +03:00
parent fbbb96409d
commit 37155901ef
3 changed files with 37 additions and 25 deletions

View File

@ -24,6 +24,22 @@ class CardWidget extends StatelessWidget {
}
}
if (card.conditions.isNotEmpty) {
bool showCardByConditions = false;
for (var condition in card.conditions) {
Entity conditionEntity = HomeAssistant().entities.get(condition['entity']);
if (conditionEntity != null &&
(condition['state'] != null && conditionEntity.state == condition['state']) ||
(condition['state_not'] != null && conditionEntity.state != condition['state_not'])
) {
showCardByConditions = true;
}
}
if (!showCardByConditions) {
return Container(width: 0.0, height: 0.0,);
}
}
switch (card.type) {
case CardType.entities: {