Resolves #336 Replace 'unknown' state with '-'. Show displayState for badges
This commit is contained in:
parent
b63cddfa46
commit
cbc56a8105
@ -154,7 +154,7 @@ class Entity {
|
|||||||
entityId = rawData["entity_id"];
|
entityId = rawData["entity_id"];
|
||||||
deviceClass = attributes["device_class"];
|
deviceClass = attributes["device_class"];
|
||||||
state = rawData["state"];
|
state = rawData["state"];
|
||||||
displayState = Entity.StateByDeviceClass["$deviceClass.$state"] ?? state;
|
displayState = Entity.StateByDeviceClass["$deviceClass.$state"] ?? (state.toLowerCase() == 'unknown' ? '-' : state);
|
||||||
_lastUpdated = DateTime.tryParse(rawData["last_updated"]);
|
_lastUpdated = DateTime.tryParse(rawData["last_updated"]);
|
||||||
entityPicture = _getEntityPictureUrl(webHost);
|
entityPicture = _getEntityPictureUrl(webHost);
|
||||||
}
|
}
|
||||||
|
@ -42,25 +42,25 @@ class BadgeWidget extends StatelessWidget {
|
|||||||
size: iconSize,
|
size: iconSize,
|
||||||
color: Colors.black
|
color: Colors.black
|
||||||
);
|
);
|
||||||
onBadgeTextValue = entityModel.entityWrapper.entity.state;
|
onBadgeTextValue = entityModel.entityWrapper.entity.displayState;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
double stateFontSize;
|
double stateFontSize;
|
||||||
if (entityModel.entityWrapper.entity.state.length <= 3) {
|
if (entityModel.entityWrapper.entity.displayState.length <= 3) {
|
||||||
stateFontSize = 18.0;
|
stateFontSize = 18.0;
|
||||||
} else if (entityModel.entityWrapper.entity.state.length <= 4) {
|
} else if (entityModel.entityWrapper.entity.displayState.length <= 4) {
|
||||||
stateFontSize = 15.0;
|
stateFontSize = 15.0;
|
||||||
} else if (entityModel.entityWrapper.entity.state.length <= 6) {
|
} else if (entityModel.entityWrapper.entity.displayState.length <= 6) {
|
||||||
stateFontSize = 10.0;
|
stateFontSize = 10.0;
|
||||||
} else if (entityModel.entityWrapper.entity.state.length <= 10) {
|
} else if (entityModel.entityWrapper.entity.displayState.length <= 10) {
|
||||||
stateFontSize = 8.0;
|
stateFontSize = 8.0;
|
||||||
}
|
}
|
||||||
onBadgeTextValue = entityModel.entityWrapper.entity.unitOfMeasurement;
|
onBadgeTextValue = entityModel.entityWrapper.entity.unitOfMeasurement;
|
||||||
badgeIcon = Center(
|
badgeIcon = Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"${entityModel.entityWrapper.entity.state}",
|
"${entityModel.entityWrapper.entity.displayState}",
|
||||||
overflow: TextOverflow.fade,
|
overflow: TextOverflow.fade,
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
Reference in New Issue
Block a user