Resolves #165 Hide controls for unavailable lights
This commit is contained in:
		| @@ -98,7 +98,7 @@ class _LightControlsWidgetState extends State<LightControlsWidget> { | ||||
|   } | ||||
|  | ||||
|   Widget _buildBrightnessControl(LightEntity entity) { | ||||
|     if ((entity.supportBrightness) && (_tmpBrightness != null)) { | ||||
|     if ((entity.supportBrightness) && (_tmpBrightness != null) && (entity.state != "unavailable")) { | ||||
|       return Column( | ||||
|         crossAxisAlignment: CrossAxisAlignment.start, | ||||
|         children: <Widget>[ | ||||
|   | ||||
| @@ -30,15 +30,22 @@ class _SwitchStateWidgetState extends State<SwitchStateWidget> { | ||||
|     final entityModel = EntityModel.of(context); | ||||
|     final entity = entityModel.entity; | ||||
|     Widget result; | ||||
|     if ((entity.attributes["assumed_state"] == null) || (entity.attributes["assumed_state"] == false)) { | ||||
|       result = Switch( | ||||
|     if (entity.state == "unavailable") { | ||||
|       return SimpleEntityState(); | ||||
|     } else if ((entity.attributes["assumed_state"] == null) || (entity.attributes["assumed_state"] == false)) { | ||||
|       return SizedBox( | ||||
|         height: 32.0, | ||||
|         child: Switch( | ||||
|           value: entity.assumedState == 'on', | ||||
|           onChanged: ((switchState) { | ||||
|             _setNewState(switchState, entity); | ||||
|           }), | ||||
|         ) | ||||
|       ); | ||||
|     } else { | ||||
|       result = Row( | ||||
|       return SizedBox( | ||||
|         height: 32.0, | ||||
|         child: Row( | ||||
|           crossAxisAlignment: CrossAxisAlignment.start, | ||||
|           children: <Widget>[ | ||||
|             IconButton( | ||||
| @@ -54,11 +61,8 @@ class _SwitchStateWidgetState extends State<SwitchStateWidget> { | ||||
|                 iconSize: Entity.iconSize | ||||
|             ) | ||||
|           ], | ||||
|       ); | ||||
|     } | ||||
|     return SizedBox( | ||||
|       height: 32.0, | ||||
|       child: result, | ||||
|         ), | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user