WIP #142 Alarm control panel
This commit is contained in:
		
							
								
								
									
										10
									
								
								lib/entity_class/alarm_control_panel.class.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								lib/entity_class/alarm_control_panel.class.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | part of '../main.dart'; | ||||||
|  |  | ||||||
|  | class AlarmControlPanelEntity extends Entity { | ||||||
|  |   AlarmControlPanelEntity(Map rawData) : super(rawData); | ||||||
|  |  | ||||||
|  |   @override | ||||||
|  |   Widget _buildAdditionalControlsForPage(BuildContext context) { | ||||||
|  |     return AlarmControlPanelControlsWidget(); | ||||||
|  |   } | ||||||
|  | } | ||||||
| @@ -86,6 +86,9 @@ class EntityCollection { | |||||||
|       case "fan": { |       case "fan": { | ||||||
|         return FanEntity(rawEntityData); |         return FanEntity(rawEntityData); | ||||||
|       } |       } | ||||||
|  |       case "alarm_control_panel": { | ||||||
|  |         return AlarmControlPanelEntity(rawEntityData); | ||||||
|  |       } | ||||||
|       default: { |       default: { | ||||||
|         return Entity(rawEntityData); |         return Entity(rawEntityData); | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -0,0 +1,44 @@ | |||||||
|  | part of '../../main.dart'; | ||||||
|  |  | ||||||
|  | class AlarmControlPanelControlsWidget extends StatefulWidget { | ||||||
|  |  | ||||||
|  |   @override | ||||||
|  |   _AlarmControlPanelControlsWidgetWidgetState createState() => _AlarmControlPanelControlsWidgetWidgetState(); | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  | class _AlarmControlPanelControlsWidgetWidgetState extends State<AlarmControlPanelControlsWidget> { | ||||||
|  |  | ||||||
|  |   void _disarm(AlarmControlPanelEntity entity, String code) { | ||||||
|  |     eventBus.fire(new ServiceCallEvent( | ||||||
|  |           entity.domain, "alarm_disarm", entity.entityId, | ||||||
|  |           {"code": "$code"})); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   @override | ||||||
|  |   Widget build(BuildContext context) { | ||||||
|  |     final entityModel = EntityModel.of(context); | ||||||
|  |     final AlarmControlPanelEntity entity = entityModel.entityWrapper.entity; | ||||||
|  |     return Column( | ||||||
|  |       crossAxisAlignment: CrossAxisAlignment.center, | ||||||
|  |  | ||||||
|  |       children: <Widget>[ | ||||||
|  |         TextField( | ||||||
|  |             //focusNode: _focusNode, | ||||||
|  |             obscureText: true, | ||||||
|  |             /*controller: new TextEditingController.fromValue( | ||||||
|  |                 new TextEditingValue( | ||||||
|  |                     text: _tmpValue, | ||||||
|  |                     selection: | ||||||
|  |                     new TextSelection.collapsed(offset: _tmpValue.length) | ||||||
|  |                 ) | ||||||
|  |             ),*/ | ||||||
|  |             onChanged: (value) { | ||||||
|  |               Logger.d('Alarm code: $value'); | ||||||
|  |             }) | ||||||
|  |       ], | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -34,6 +34,7 @@ part 'entity_class/lock_entity.class.dart'; | |||||||
| part 'entity_class/group_entity.class.dart'; | part 'entity_class/group_entity.class.dart'; | ||||||
| part 'entity_class/fan_entity.class.dart'; | part 'entity_class/fan_entity.class.dart'; | ||||||
| part 'entity_class/automation_entity.dart'; | part 'entity_class/automation_entity.dart'; | ||||||
|  | part 'entity_class/alarm_control_panel.class.dart'; | ||||||
| part 'entity_widgets/common/badge.dart'; | part 'entity_widgets/common/badge.dart'; | ||||||
| part 'entity_widgets/model_widgets.dart'; | part 'entity_widgets/model_widgets.dart'; | ||||||
| part 'entity_widgets/default_entity_container.dart'; | part 'entity_widgets/default_entity_container.dart'; | ||||||
| @@ -69,6 +70,7 @@ part 'entity_widgets/controls/cover_controls.dart'; | |||||||
| part 'entity_widgets/controls/light_controls.dart'; | part 'entity_widgets/controls/light_controls.dart'; | ||||||
| part 'entity_widgets/controls/media_player_widgets.dart'; | part 'entity_widgets/controls/media_player_widgets.dart'; | ||||||
| part 'entity_widgets/controls/fan_controls.dart'; | part 'entity_widgets/controls/fan_controls.dart'; | ||||||
|  | part 'entity_widgets/controls/alarm_control_panel_controls.dart'; | ||||||
| part 'settings.page.dart'; | part 'settings.page.dart'; | ||||||
| part 'home_assistant.class.dart'; | part 'home_assistant.class.dart'; | ||||||
| part 'log.page.dart'; | part 'log.page.dart'; | ||||||
|   | |||||||
| @@ -24,7 +24,14 @@ class MaterialDesignIcons { | |||||||
|     "cover.opening": "mdi:window-open", |     "cover.opening": "mdi:window-open", | ||||||
|     "lock.locked": "mdi:lock", |     "lock.locked": "mdi:lock", | ||||||
|     "lock.unlocked": "mdi:lock-open", |     "lock.unlocked": "mdi:lock-open", | ||||||
|     "fan": "mdi:fan" |     "fan": "mdi:fan", | ||||||
|  |     "alarm_control_panel.disarmed" : "mdi:bell-outline", | ||||||
|  |     "alarm_control_panel.armed_home" : "mdi:bell-plus", | ||||||
|  |     "alarm_control_panel.armed_away" : "mdi:bell", | ||||||
|  |     "alarm_control_panel.armed_night" : "mdi:bell-sleep", | ||||||
|  |     "alarm_control_panel.armed_custom_bypass" : "mdi:bell-sleep", | ||||||
|  |     "alarm_control_panel.triggered" : "mdi:bell-ring", | ||||||
|  |     "alarm_control_panel" : "mdi:bell" | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   static Map _defaultIconsByDeviceClass = { |   static Map _defaultIconsByDeviceClass = { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user