@@ -871,6 +871,30 @@ def get_week_profile_status(self, week_profile_id, dt=datetime.datetime.today())
871871 _LOGGER .debug ('Status at %s on weekday %s is %s' , target , dt .weekday (), nobo .API .DICT_WEEK_PROFILE_STATUS_TO_NAME [status ])
872872 return nobo .API .DICT_WEEK_PROFILE_STATUS_TO_NAME [status ]
873873
874+ def get_zone_override_mode (self , zone_id ):
875+ """
876+ Get the override mode of a zone.
877+
878+ :param zone_id: the zone id in question
879+
880+ :return: the override mode for the zone
881+ """
882+ mode = nobo .API .NAME_NORMAL
883+ for o in self .overrides :
884+ if self .overrides [o ]['mode' ] == '0' :
885+ continue # "normal" overrides
886+ elif (self .overrides [o ]['target_type' ] == nobo .API .OVERRIDE_TARGET_ZONE
887+ and self .overrides [o ]['target_id' ] == zone_id ):
888+ mode = nobo .API .DICT_OVERRIDE_MODE_TO_NAME [self .overrides [o ]['mode' ]]
889+ # Takes precedence over global override
890+ break
891+ elif (self .zones [zone_id ]['override_allowed' ] == '1'
892+ and self .overrides [o ]['target_type' ] == nobo .API .OVERRIDE_TARGET_GLOBAL ):
893+ mode = nobo .API .DICT_OVERRIDE_MODE_TO_NAME [self .overrides [o ]['mode' ]]
894+
895+ _LOGGER .debug ('Current override for zone %s is %s' , self .zones [zone_id ]['name' ], mode )
896+ return mode
897+
874898 def get_current_zone_mode (self , zone_id , now = datetime .datetime .today ()):
875899 """
876900 Get the mode of a zone at a certain time. If the zone is overridden only now is possible.
@@ -881,22 +905,9 @@ def get_current_zone_mode(self, zone_id, now=datetime.datetime.today()):
881905 :return: the mode for the zone
882906 """
883907 current_time = (now .hour * 100 ) + now .minute
884- current_mode = ''
885-
886- # check if the zone is overridden and to which mode
887- if self .zones [zone_id ]['override_allowed' ] == '1' :
888- for o in self .overrides :
889- if self .overrides [o ]['mode' ] == '0' :
890- continue # "normal" overrides
891- elif self .overrides [o ]['target_type' ] == nobo .API .OVERRIDE_TARGET_ZONE :
892- if self .overrides [o ]['target_id' ] == zone_id :
893- current_mode = nobo .API .DICT_OVERRIDE_MODE_TO_NAME [self .overrides [o ]['mode' ]]
894- break
895- elif self .overrides [o ]['target_type' ] == nobo .API .OVERRIDE_TARGET_GLOBAL :
896- current_mode = nobo .API .DICT_OVERRIDE_MODE_TO_NAME [self .overrides [o ]['mode' ]]
897-
898- # no override - find mode from week profile
899- if not current_mode :
908+ current_mode = self .get_zone_override_mode (zone_id )
909+ if current_mode == nobo .API .NAME_NORMAL :
910+ # no override - find mode from week profile
900911 current_mode = self .get_week_profile_status (self .zones [zone_id ]['week_profile_id' ], now )
901912
902913 _LOGGER .debug ('Current mode for zone %s at %s is %s' , self .zones [zone_id ]['name' ], current_time , current_mode )
0 commit comments