| @@ -95,7 +95,7 @@ class Entity { | |||||||
|   bool get isBadge => Entity.badgeDomains.contains(domain); |   bool get isBadge => Entity.badgeDomains.contains(domain); | ||||||
|   String get icon => attributes["icon"] ?? ""; |   String get icon => attributes["icon"] ?? ""; | ||||||
|   bool get isOn => state == EntityState.on; |   bool get isOn => state == EntityState.on; | ||||||
|   String get entityPicture => attributes["entity_picture"]; |   String get entityPicture => _getEntityPictureUrl(); | ||||||
|   String get unitOfMeasurement => attributes["unit_of_measurement"] ?? ""; |   String get unitOfMeasurement => attributes["unit_of_measurement"] ?? ""; | ||||||
|   List get childEntityIds => attributes["entity_id"] ?? []; |   List get childEntityIds => attributes["entity_id"] ?? []; | ||||||
|   String get lastUpdated => _getLastUpdatedFormatted(); |   String get lastUpdated => _getLastUpdatedFormatted(); | ||||||
| @@ -103,6 +103,19 @@ class Entity { | |||||||
|   double get doubleState => double.tryParse(state) ?? 0.0; |   double get doubleState => double.tryParse(state) ?? 0.0; | ||||||
|   int get supportedFeatures => attributes["supported_features"] ?? 0; |   int get supportedFeatures => attributes["supported_features"] ?? 0; | ||||||
|  |  | ||||||
|  |   String _getEntityPictureUrl() { | ||||||
|  |     String result = attributes["entity_picture"]; | ||||||
|  |     if (result == null) return result; | ||||||
|  |     if (!result.startsWith("http")) { | ||||||
|  |       if (result.startsWith("/")) { | ||||||
|  |         result = "$homeAssistantWebHost$result"; | ||||||
|  |       } else { | ||||||
|  |         result = "$homeAssistantWebHost/$result"; | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |     return result; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   Entity(Map rawData) { |   Entity(Map rawData) { | ||||||
|     update(rawData); |     update(rawData); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ class MediaPlayerWidget extends StatelessWidget { | |||||||
|           children: <Widget>[ |           children: <Widget>[ | ||||||
|             Flexible( |             Flexible( | ||||||
|               child: Image( |               child: Image( | ||||||
|                 image: CachedNetworkImageProvider("$homeAssistantWebHost${entity.entityPicture}"), |                 image: CachedNetworkImageProvider("${entity.entityPicture}"), | ||||||
|                 height: 240.0, |                 height: 240.0, | ||||||
|                 //width: 320.0, |                 //width: 320.0, | ||||||
|                 fit: BoxFit.contain, |                 fit: BoxFit.contain, | ||||||
|   | |||||||
| @@ -36,19 +36,11 @@ class EntityIcon extends StatelessWidget { | |||||||
|             image: DecorationImage( |             image: DecorationImage( | ||||||
|               fit:BoxFit.cover, |               fit:BoxFit.cover, | ||||||
|               image: CachedNetworkImageProvider( |               image: CachedNetworkImageProvider( | ||||||
|                 "$homeAssistantWebHost${data.entity.entityPicture}", |                 "${data.entity.entityPicture}", | ||||||
|               ), |               ), | ||||||
|             ) |             ) | ||||||
|         ), |         ), | ||||||
|       ); |       ); | ||||||
|       return CircleAvatar( |  | ||||||
|         radius: size/2+0, |  | ||||||
|  |  | ||||||
|         backgroundColor: Colors.white, |  | ||||||
|         backgroundImage: CachedNetworkImageProvider( |  | ||||||
|           "$homeAssistantWebHost${data.entity.entityPicture}", |  | ||||||
|         ), |  | ||||||
|       ); |  | ||||||
|     } else { |     } else { | ||||||
|       String iconName = data.icon; |       String iconName = data.icon; | ||||||
|       int iconCode = 0; |       int iconCode = 0; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user