Exemplo n.º 1
0
def water_back_off():
    """month=05-09;hour=07;minute=57;is_active=false"""
    L.l.info('water back off')
    rule_common.update_custom_relay('back_valve_relay', False)
    # let the pump build some pressure
    time.sleep(5)
    # pump off if no other zone is on?
    back_pump_off()
Exemplo n.º 2
0
 def set_power_status(self, power_is_on, exported_watts=None):
     valid_power_status = power_is_on
     if not power_is_on and self.state == DeviceState.USER_FORCED_START:
         # do not stop the relay, as user forced a start
         L.l.info("Not stopping forced start device {}, power={}".format(
             self.RELAY_NAME, self.is_power_on()))
         valid_power_status = None
     if not power_is_on and self.is_power_on(
     ) and not self.can_state_change():
         L.l.info("Cannot stop already started device {}, breaks={}".format(
             self.RELAY_NAME, self.DEVICE_SUPPORTS_BREAKS))
         valid_power_status = None
     if not power_is_on and not self.can_stop_relay():
         L.l.info("Cannot stop device {} yet, breaks={}".format(
             self.RELAY_NAME, self.DEVICE_SUPPORTS_BREAKS))
         valid_power_status = None
     if valid_power_status is not None and self.is_power_on(
     ) != valid_power_status:
         rule_common.update_custom_relay(relay_pin_name=self.RELAY_NAME,
                                         power_is_on=valid_power_status)
         self.last_state_change = datetime.now()
         self.power_status_changed()
         if valid_power_status:
             self.last_state_on = datetime.now()
Exemplo n.º 3
0
 def set_power_status(self, power_is_on):
     if (self.state == DeviceState.USER_FORCED_STOP
             or not self.DEVICE_SUPPORTS_BREAKS) and power_is_on is False:
         # do not start the relay, as user forced a stop
         L.l.info("Not starting relay {}, state={} power={}".format(
             self.RELAY_NAME, self.state, power_is_on))
         pass
     elif self.state == DeviceState.USER_FORCED_START and power_is_on is False:
         # do not stop the relay, as user forced a start
         L.l.info("Not stopping relay {}, state={} power={}".format(
             self.RELAY_NAME, self.state, power_is_on))
     else:
         if self.can_state_change():
             if self.get_power_status() != power_is_on:
                 valid_power_status = None
                 if not power_is_on:
                     if self.can_stop_relay():
                         valid_power_status = power_is_on
                     else:
                         # not allowed to stop the relay
                         pass
                 else:
                     valid_power_status = power_is_on
                 if valid_power_status is not None:
                     rule_common.update_custom_relay(
                         relay_pin_name=self.RELAY_NAME,
                         power_is_on=valid_power_status)
                     self.last_state_change = datetime.now()
                     if valid_power_status:
                         self.last_state_on = datetime.now()
             else:
                 L.l.info("Relay {} state already {}, power={}".format(
                     self.RELAY_NAME, self.state, self.power_is_on))
                 pass
             if power_is_on:
                 if self.state == DeviceState.NO_INIT or self.state == DeviceState.JOB_FINISHED:
                     if power_is_on:
                         self.state = DeviceState.FIRST_START
                         L.l.info(
                             "Was first relay start {}, state={}".format(
                                 self.RELAY_NAME, self.state))
                     else:
                         self.state = DeviceState.AUTO_STOP
                         L.l.info("Was auto stop relay {}, state={}".format(
                             self.RELAY_NAME, self.state))
                 elif self.state == DeviceState.FIRST_START:
                     self.state = DeviceState.AUTO_START
                     L.l.info("Now is auto start relay {}, state={}".format(
                         self.RELAY_NAME, self.state))
                 elif self.state == DeviceState.AUTO_STOP:
                     self.state = DeviceState.AUTO_START
                     L.l.info("Was auto start relay {}, state={}".format(
                         self.RELAY_NAME, self.state))
                 elif self.state == DeviceState.AUTO_START:
                     # already on
                     L.l.info("Keep relay on {}, state={}".format(
                         self.RELAY_NAME, self.state))
                     pass
             else:
                 if self.state in [
                         DeviceState.AUTO_START, DeviceState.NO_INIT,
                         DeviceState.FIRST_START
                 ]:
                     L.l.info("Auto stop relay {}, state={}".format(
                         self.RELAY_NAME, self.state))
                     self.state = DeviceState.AUTO_STOP
                 else:
                     L.l.info("Unexpected state relay {}, state={}".format(
                         self.RELAY_NAME, self.state))
         else:
             L.l.info("Not changing relay {}, state={}".format(
                 self.RELAY_NAME, self.state))
Exemplo n.º 4
0
def front_lights_on():
    rule_common.update_custom_relay('front_lights_relay', True)
Exemplo n.º 5
0
def water_back_main_off():
    """month=05-09;hour=07;minute=57;is_active=false"""
    L.l.info('water back main off')
    rule_common.update_custom_relay('front_main_valve_relay', False)
    rule_common.update_custom_relay('back_valve_relay', False)
Exemplo n.º 6
0
def water_back_on():
    """month=05-09;hour=07;minute=54;is_active=false"""
    L.l.info('water back on')
    back_pump_on()
    rule_common.update_custom_relay('back_valve_relay', True)
Exemplo n.º 7
0
def water_front_main_on():
    """month=05-09;hour=07;minute=50;is_active=false"""
    L.l.info('water front main on')
    rule_common.update_custom_relay('front_main_valve_relay', True)
    rule_common.update_custom_relay('front_valve_relay', True)
Exemplo n.º 8
0
def back_pump_off():
    """month=05-09;hour=07;minute=56;is_active=false"""
    L.l.info('back pump off')
    rule_common.update_custom_relay('back_pump_relay', False)
Exemplo n.º 9
0
def back_pump_on():
    """month=05-09;hour=07;minute=50;is_active=false"""
    L.l.info('Rule: back pump on')
    rule_common.update_custom_relay('back_pump_relay', True)
Exemplo n.º 10
0
def toggle_gate():
    L.l.info('Rule: toggle gate relay on {}'.format(datetime.datetime.now()))
    rule_common.update_custom_relay('gate_relay', True)
    time.sleep(1)
    L.l.info('Rule: toggle gate relay off{}'.format(datetime.datetime.now()))
    rule_common.update_custom_relay('gate_relay', False)