9
9
10
10
from .global_variables import GlobalVariables as Gb
11
11
from .const import (RED_ALERT , LINK , RLINK , RARROW ,
12
- IPHONE , IPAD , WATCH , AIRPODS , ICLOUD , OTHER ,
12
+ IPHONE , IPAD , WATCH , AIRPODS , ICLOUD , OTHER , HOME , NONE ,
13
13
DEVICE_TYPE_FNAME , DEVICE_TYPE_FNAMES , MOBAPP , NO_MOBAPP ,
14
14
INACTIVE_DEVICE , HOME_DISTANCE ,
15
15
PICTURE_WWW_STANDARD_DIRS , CONF_PICTURE_WWW_DIRS ,
@@ -619,24 +619,35 @@ def form_add_device(self):
619
619
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
620
620
def form_update_device (self ):
621
621
622
+ # Build Other Tracking Parameters values text
623
+ log_zones_fnames = [zone_dname (zone ) for zone in self .conf_device [CONF_LOG_ZONES ] if zone .startswith ('name' ) is False ]
624
+ tfz_fnames = [zone_dname (zone ) for zone in self .conf_device [CONF_TRACK_FROM_ZONES ]]
625
+ device_type_fname = DEVICE_TYPE_FNAME (self ._parm_or_device (CONF_DEVICE_TYPE ))
626
+ otp_msg = (f"Type ({ device_type_fname } ), "
627
+ f"inZoneInterval ({ format_timer (self .conf_device [CONF_INZONE_INTERVAL ]* 60 )} )" )
628
+ otp_msg += ", FixedInterval"
629
+ if self .conf_device [CONF_FIXED_INTERVAL ] > 0 :
630
+ otp_msg += f" ({ format_timer (self .conf_device [CONF_FIXED_INTERVAL ]* 60 )} )"
631
+ otp_msg += ", LogZones"
632
+ if self .conf_device [CONF_LOG_ZONES ] != [NONE ]:
633
+ otp_msg += f" ({ list_to_str (log_zones_fnames )} )"
634
+ otp_msg += ", TrackFromZone"
635
+ if self .conf_device [CONF_TRACK_FROM_ZONES ] != [HOME ]:
636
+ otp_msg += f" ({ list_to_str (tfz_fnames )} )"
637
+ otp_msg += ", PrimaryTrackFromZone"
638
+ if self .conf_device [CONF_TRACK_FROM_BASE_ZONE ] != HOME :
639
+ otp_msg += f" ({ zone_dname (self .conf_device [CONF_TRACK_FROM_BASE_ZONE ])} )"
640
+ otp_action_item = ACTION_LIST_OPTIONS [
641
+ 'update_other_device_parameters' ].replace ('^otp_msg' , otp_msg )
642
+
622
643
error_key = ''
623
644
self .errors = self .errors or {}
624
645
self .actions_list = []
646
+ self .actions_list .append (otp_action_item )
625
647
self .actions_list .append (ACTION_LIST_OPTIONS ['save' ])
626
648
self .actions_list .append (ACTION_LIST_OPTIONS ['cancel_goto_menu' ])
627
649
self .actions_list .append (ACTION_LIST_OPTIONS ['cancel_goto_select_device' ])
628
650
629
- # Display Advanced Tracking Parameters
630
- log_zones_fnames = [zone_dname (zone ) for zone in self .conf_device [CONF_LOG_ZONES ] if zone .startswith ('Name' ) is False ]
631
- tfz_fnames = [zone_dname (zone ) for zone in self .conf_device [CONF_TRACK_FROM_ZONES ]]
632
- device_type_fname = DEVICE_TYPE_FNAME (self ._parm_or_device (CONF_DEVICE_TYPE ))
633
- RARELY_UPDATED_PARMS_HEADER = ( f"DeviceType ({ device_type_fname } ), "
634
- f"inZoneInterval ({ format_timer (self .conf_device [CONF_INZONE_INTERVAL ]* 60 )} ), "
635
- f"FixedInterval ({ format_timer (self .conf_device [CONF_FIXED_INTERVAL ]* 60 )} ), "
636
- f"LogFromZones ({ list_to_str (log_zones_fnames )} ), "
637
- f"Track-from-Zone ({ list_to_str (tfz_fnames )} ), "
638
- f"PrimaryTrackFromZone ({ zone_dname (self .conf_device [CONF_TRACK_FROM_BASE_ZONE ])} )" )
639
- atp_default = [RARELY_UPDATED_PARMS_HEADER ] if self .display_rarely_updated_parms else []
640
651
641
652
devicename = self ._parm_or_device (CONF_IC3_DEVICENAME )
642
653
icloud3_fname = self ._parm_or_device (CONF_FNAME ) or ' '
@@ -725,23 +736,85 @@ def form_update_device(self):
725
736
options = dict_value_to_list (TRACKING_MODE_OPTIONS ), mode = 'dropdown' )),
726
737
})
727
738
728
- if self .display_rarely_updated_parms is False :
729
- schema .update ({
730
- vol .Optional (RARELY_UPDATED_PARMS ,
731
- default = atp_default ):
732
- cv .multi_select ([RARELY_UPDATED_PARMS_HEADER ]),
733
- })
739
+ # if self.display_rarely_updated_parms is False:
740
+ # schema.update({
741
+ # vol.Optional(RARELY_UPDATED_PARMS,
742
+ # default=atp_default):
743
+ # cv.multi_select([RARELY_UPDATED_PARMS_HEADER]),
744
+ # })
745
+
746
+ # if self.display_rarely_updated_parms:
747
+ # device_type_fname = DEVICE_TYPE_FNAME(self._parm_or_device(CONF_DEVICE_TYPE))
748
+ # schema.update({
749
+ # vol.Required(CONF_DEVICE_TYPE,
750
+ # default=self._option_parm_to_text(CONF_DEVICE_TYPE, DEVICE_TYPE_FNAMES)):
751
+ # selector.SelectSelector(selector.SelectSelectorConfig(
752
+ # options=dict_value_to_list(DEVICE_TYPE_FNAMES), mode='dropdown')),
753
+ # vol.Required(CONF_INZONE_INTERVAL,
754
+ # default=self.conf_device[CONF_INZONE_INTERVAL]):
755
+ # # default=self._parm_or_device(CONF_INZONE_INTERVAL)):
756
+ # selector.NumberSelector(selector.NumberSelectorConfig(
757
+ # min=5, max=480, step=5, unit_of_measurement='minutes')),
758
+ # vol.Required(CONF_FIXED_INTERVAL,
759
+ # default=self.conf_device[CONF_FIXED_INTERVAL]):
760
+ # selector.NumberSelector(selector.NumberSelectorConfig(
761
+ # min=0, max=480, step=5, unit_of_measurement='minutes')),
762
+ # vol.Optional(CONF_LOG_ZONES,
763
+ # default=self._parm_or_device(CONF_LOG_ZONES)):
764
+ # cv.multi_select(six_item_dict(log_zones_key_text)),
765
+ # vol.Required(CONF_TRACK_FROM_ZONES,
766
+ # default=self._parm_or_device(CONF_TRACK_FROM_ZONES)):
767
+ # cv.multi_select(six_item_dict(self.zone_name_key_text)),
768
+ # #cv.multi_select(self.zone_name_key_text),
769
+ # vol.Required(CONF_TRACK_FROM_BASE_ZONE,
770
+ # default=self._option_parm_to_text(CONF_TRACK_FROM_BASE_ZONE,
771
+ # self.zone_name_key_text, conf_device=True)):
772
+ # selector.SelectSelector(selector.SelectSelectorConfig(
773
+ # options=dict_value_to_list(self.zone_name_key_text), mode='dropdown')),
774
+ # })
734
775
735
- if self .display_rarely_updated_parms :
736
- device_type_fname = DEVICE_TYPE_FNAME (self ._parm_or_device (CONF_DEVICE_TYPE ))
737
- schema .update ({
776
+ schema .update ({
777
+ vol .Required ('action_items' ,
778
+ default = self .action_default_text ('save' )):
779
+ selector .SelectSelector (selector .SelectSelectorConfig (
780
+ options = self .actions_list , mode = 'list' )),
781
+ })
782
+
783
+ return vol .Schema (schema )
784
+
785
+ #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
786
+ # UPDATE OTHER DEVICE PARAMETERS
787
+ #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
788
+ def form_update_other_device_parameters (self ):
789
+
790
+ # Display Advanced Tracking Parameters
791
+ # log_zones_fnames = [zone_dname(zone) for zone in self.conf_device[CONF_LOG_ZONES] if zone.startswith('Name') is False]
792
+ # tfz_fnames = [zone_dname(zone) for zone in self.conf_device[CONF_TRACK_FROM_ZONES]]
793
+ # device_type_fname = DEVICE_TYPE_FNAME(self._parm_or_device(CONF_DEVICE_TYPE))
794
+ # RARELY_UPDATED_PARMS_HEADER = ( f"DeviceType ({device_type_fname}), "
795
+ # f"inZoneInterval ({format_timer(self.conf_device[CONF_INZONE_INTERVAL]*60)}), "
796
+ # f"FixedInterval ({format_timer(self.conf_device[CONF_FIXED_INTERVAL]*60)}), "
797
+ # f"LogFromZones ({list_to_str(log_zones_fnames)}), "
798
+ # f"Track-from-Zone ({list_to_str(tfz_fnames)}), "
799
+ # f"PrimaryTrackFromZone ({zone_dname(self.conf_device[CONF_TRACK_FROM_BASE_ZONE])})")
800
+ # atp_default = [RARELY_UPDATED_PARMS_HEADER] if self.display_rarely_updated_parms else []
801
+
802
+ self .actions_list = []
803
+ self .actions_list .append (ACTION_LIST_OPTIONS ['save' ])
804
+ self .actions_list .append (ACTION_LIST_OPTIONS ['cancel_goto_previous' ])
805
+
806
+ log_zones_key_text = {'none' : 'None' }
807
+ log_zones_key_text .update (self .zone_name_key_text )
808
+ log_zones_key_text .update (LOG_ZONES_KEY_TEXT )
809
+
810
+ device_type_fname = DEVICE_TYPE_FNAME (self ._parm_or_device (CONF_DEVICE_TYPE ))
811
+ return vol .Schema ({
738
812
vol .Required (CONF_DEVICE_TYPE ,
739
813
default = self ._option_parm_to_text (CONF_DEVICE_TYPE , DEVICE_TYPE_FNAMES )):
740
814
selector .SelectSelector (selector .SelectSelectorConfig (
741
815
options = dict_value_to_list (DEVICE_TYPE_FNAMES ), mode = 'dropdown' )),
742
816
vol .Required (CONF_INZONE_INTERVAL ,
743
817
default = self .conf_device [CONF_INZONE_INTERVAL ]):
744
- # default=self._parm_or_device(CONF_INZONE_INTERVAL)):
745
818
selector .NumberSelector (selector .NumberSelectorConfig (
746
819
min = 5 , max = 480 , step = 5 , unit_of_measurement = 'minutes' )),
747
820
vol .Required (CONF_FIXED_INTERVAL ,
@@ -754,44 +827,37 @@ def form_update_device(self):
754
827
vol .Required (CONF_TRACK_FROM_ZONES ,
755
828
default = self ._parm_or_device (CONF_TRACK_FROM_ZONES )):
756
829
cv .multi_select (six_item_dict (self .zone_name_key_text )),
757
- #cv.multi_select(self.zone_name_key_text),
758
830
vol .Required (CONF_TRACK_FROM_BASE_ZONE ,
759
831
default = self ._option_parm_to_text (CONF_TRACK_FROM_BASE_ZONE ,
760
832
self .zone_name_key_text , conf_device = True )):
761
833
selector .SelectSelector (selector .SelectSelectorConfig (
762
834
options = dict_value_to_list (self .zone_name_key_text ), mode = 'dropdown' )),
763
- })
764
835
765
- schema .update ({
766
836
vol .Required ('action_items' ,
767
- default = self .action_default_text ('save' )):
768
- selector .SelectSelector (selector .SelectSelectorConfig (
769
- options = self .actions_list , mode = 'list' )),
770
- })
771
-
772
- return vol .Schema (schema )
837
+ default = self .action_default_text ('save' )):
838
+ selector .SelectSelector (selector .SelectSelectorConfig (
839
+ options = self .actions_list , mode = 'list' )),
840
+ })
773
841
774
842
775
843
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
776
- # DELETE DEVICE
844
+ # DASHBOARD BUILDER
777
845
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
778
- # def form_delete_device(self):
779
- # self.actions_list = DEVICE_DELETE_ACTIONS.copy()
780
- # device_text = ( f"{self.conf_device[CONF_FNAME]} "
781
- # f"({self.conf_device[CONF_IC3_DEVICENAME]})")
782
- # device_selected = self.device_items_list[self.conf_device_idx]
783
-
784
- # # The first item is 'Delete this device, add the selected device's info
785
- # return vol.Schema({
786
- # vol.Required('device_selected',
787
- # default=device_selected):
788
- # selector.SelectSelector(selector.SelectSelectorConfig(
789
- # options=[device_selected], mode='list')),
790
- # vol.Required('action_items',
791
- # default=self.action_default_text('delete_device_cancel')):
792
- # selector.SelectSelector(
793
- # selector.SelectSelectorConfig(options=self.actions_list, mode='list')),
794
- # })
846
+ def form_dashboard_builder (self ):
847
+ self .actions_list = ACTION_LIST_ITEMS_BASE .copy ()
848
+ action_default = 'cancel_goto_menu'
849
+
850
+
851
+ return vol .Schema ({
852
+ # vol.Optional('under_construction',
853
+ # default='Under Construction'):
854
+ # cv.multi_select(['Under Construction']),
855
+ vol .Required ('action_items' ,
856
+ default = self .action_default_text (action_default )):
857
+ selector .SelectSelector (
858
+ selector .SelectSelectorConfig (options = self .actions_list , mode = 'list' )),
859
+ })
860
+
795
861
796
862
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
797
863
# TOOLS
0 commit comments