From c76d3d68c887fe1fffa390947569da83cf87fbad Mon Sep 17 00:00:00 2001 From: estevez-dev Date: Wed, 21 Aug 2019 18:28:07 +0300 Subject: [PATCH] Resolves #406 Minimum light brightness is set to 1 isntead of 0 --- .../controls/light_controls.dart | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/entity_widgets/controls/light_controls.dart b/lib/entity_widgets/controls/light_controls.dart index 1017251..66715b2 100644 --- a/lib/entity_widgets/controls/light_controls.dart +++ b/lib/entity_widgets/controls/light_controls.dart @@ -17,7 +17,7 @@ class _LightControlsWidgetState extends State { String _tmpEffect; void _resetState(LightEntity entity) { - _tmpBrightness = entity.brightness ?? 0; + _tmpBrightness = entity.brightness ?? 1; _tmpWhiteValue = entity.whiteValue ?? 0; _tmpColorTemp = entity.colorTemp ?? entity.minMireds?.toInt(); _tmpColor = entity.color ?? _tmpColor; @@ -28,15 +28,9 @@ class _LightControlsWidgetState extends State { setState(() { _tmpBrightness = value.round(); _changedHere = true; - if (_tmpBrightness > 0) { - eventBus.fire(new ServiceCallEvent( - entity.domain, "turn_on", entity.entityId, - {"brightness": _tmpBrightness})); - } else { - eventBus.fire(new ServiceCallEvent( - entity.domain, "turn_off", entity.entityId, - null)); - } + eventBus.fire(new ServiceCallEvent( + entity.domain, "turn_on", entity.entityId, + {"brightness": _tmpBrightness})); }); } @@ -114,10 +108,10 @@ class _LightControlsWidgetState extends State { _tmpBrightness = value.round(); }); }, - min: 0.0, + min: 1.0, max: 255.0, onChangeEnd: (value) => _setBrightness(entity, value), - value: _tmpBrightness == null ? 0.0 : _tmpBrightness.toDouble(), + value: _tmpBrightness == null ? 1.0 : _tmpBrightness.toDouble(), leading: Icon(Icons.brightness_5), title: "Brightness", );