diff --git a/lib/entity_class/entity.class.dart b/lib/entity_class/entity.class.dart index 9b40c97..0d1c84c 100644 --- a/lib/entity_class/entity.class.dart +++ b/lib/entity_class/entity.class.dart @@ -518,9 +518,7 @@ class LightEntity extends Entity { double get minMireds => _getDoubleAttributeValue("min_mireds"); Color get color => _getColor(); bool get isAdditionalControls => ((attributes["supported_features"] != null) && (attributes["supported_features"] != 0)); - List get effectList => attributes["effect_list"] != null - ? (attributes["effect_list"] as List).cast() - : null; + List get effectList => _getEffectList(); LightEntity(Map rawData) : super(rawData); @@ -537,6 +535,15 @@ class LightEntity extends Entity { } } + List _getEffectList() { + if (attributes["effect_list"] != null) { + List result = (attributes["effect_list"] as List).cast(); + return result; + } else { + return null; + } + } + @override Widget _buildStatePart(BuildContext context) { return SwitchStateWidget(); diff --git a/lib/entity_class/stateful_widgets.dart b/lib/entity_class/stateful_widgets.dart index 063470e..ef26077 100644 --- a/lib/entity_class/stateful_widgets.dart +++ b/lib/entity_class/stateful_widgets.dart @@ -780,11 +780,15 @@ class _LightControlsWidgetState extends State { int _tmpColorTemp; Color _tmpColor; bool _changedHere = false; + String _tmpEffect; + String _tmpFlash; void _resetState(LightEntity entity) { _tmpBrightness = entity.brightness; _tmpColorTemp = entity.colorTemp; _tmpColor = entity.color; + _tmpEffect = null; + _tmpFlash = null; } void _setBrightness(LightEntity entity, double value) { @@ -830,6 +834,30 @@ class _LightControlsWidgetState extends State { }); } + void _setEffect(LightEntity entity, String value) { + setState(() { + _tmpEffect = value; + _changedHere = true; + if (_tmpEffect != null) { + eventBus.fire(new ServiceCallEvent( + entity.domain, "turn_on", entity.entityId, + {"effect": "$value"})); + } + }); + } + + void _setFlash(LightEntity entity, String value) { + setState(() { + _tmpFlash = value; + _changedHere = true; + if (_tmpFlash != null) { + eventBus.fire(new ServiceCallEvent( + entity.domain, "turn_on", entity.entityId, + {"flash": "$value"})); + } + }); + } + @override Widget build(BuildContext context) { final entityModel = EntityModel.of(context); @@ -845,10 +873,7 @@ class _LightControlsWidgetState extends State { _buildBrightnessControl(entity), _buildColorTempControl(entity), _buildColorControl(entity), - _buildEffectControl(entity), - _buildFlashControl(entity), - _buildTransitionControl(entity), - _buildWhiteValueControl(entity) + _buildEffectControl(entity) ], ); } @@ -990,31 +1015,12 @@ class _LightControlsWidgetState extends State { Widget _buildEffectControl(LightEntity entity) { if (entity.supportEffect) { - return Text("Effect is not supported yet =("); - } else { - return Container(width: 0.0, height: 0.0); - } - } - - Widget _buildFlashControl(LightEntity entity) { - if (entity.supportFlash) { - return Text("Flash is not supported yet =("); - } else { - return Container(width: 0.0, height: 0.0); - } - } - - Widget _buildTransitionControl(LightEntity entity) { - if (entity.supportTransition) { - return Text("Transition is not supported yet =("); - } else { - return Container(width: 0.0, height: 0.0); - } - } - - Widget _buildWhiteValueControl(LightEntity entity) { - if (entity.supportWhiteValue) { - return Text("White value is not supported yet =("); + return ModeSelectorWidget( + onChange: (effect) => _setEffect(entity, effect), + caption: "Effect", + options: entity.effectList, + value: _tmpEffect + ); } else { return Container(width: 0.0, height: 0.0); } diff --git a/lib/entity_class/stateless_widgets.dart b/lib/entity_class/stateless_widgets.dart index f4dc37a..e2dac88 100644 --- a/lib/entity_class/stateless_widgets.dart +++ b/lib/entity_class/stateless_widgets.dart @@ -711,13 +711,14 @@ class ModeSelectorWidget extends StatelessWidget { child: ButtonTheme( alignedDropdown: true, child: DropdownButton( - value: "$value", + value: value, iconSize: 30.0, isExpanded: true, style: TextStyle( fontSize: valueFontSize ?? Entity.largeFontSize, color: Colors.black, ), + hint: Text("Select ${caption.toLowerCase()}"), items: options.map((String value) { return new DropdownMenuItem( value: value, diff --git a/lib/view_builder.class.dart b/lib/view_builder.class.dart index c84ea03..1f6ed36 100644 --- a/lib/view_builder.class.dart +++ b/lib/view_builder.class.dart @@ -31,7 +31,6 @@ class ViewBuilder{ Map> userGroupsList = entityCollection.getDefaultViewTopLevelEntities(); List entitiesForView = []; userGroupsList["userGroups"].forEach((groupId){ - TheLogger.log("Debug","----User defined group: $groupId"); Entity en = entityCollection.get(groupId); if (en.isGroup) { en.childEntities = entityCollection.getAll(en.childEntityIds);