Exemplo n.º 1
0
    def close(self):
        LOG.info('Stopping Program Manager')
        self.is_active = False

        while self.is_running:
            hub.sleep(1)

        current_state, _ = hvac.get_system_state()
        if current_state != states.OFF:
            hvac.set_system_state(states.OFF, current_state)
Exemplo n.º 2
0
    def run(self):
        try:
            LOG.debug('Running program interval...')
            current_state, _ = hvac.get_system_state()
            LOG.info('Current state: %s', states.print_state(current_state))

            current_temp = temp.get_current_temp()
            if not current_temp:
                LOG.error(
                    'Bailing out of current progam run... No temp data found.  Setting system state to OFF'
                )
                hvac.set_system_state(states.OFF, current_state)
                return

            current_temp_c = (current_temp - 32) * 5.0 / 9.0
            LOG.info('Current temp: %s', current_temp)

            mode = sys_mode_fac.get_system_mode()
            LOG.info('System mode: %s.  Running program: %s', mode.name(),
                     mode.program_name())

            expected_state = mode.get_state(current_temp)
            LOG.debug('Expected state: %s', states.print_state(expected_state))

            if current_state != expected_state:
                LOG.info('Setting system state to: %s',
                         states.print_state(expected_state))
                hvac.set_system_state(expected_state, current_state)
            else:
                LOG.debug(
                    'Seems like the system is already in the expected state, so I ain\'t gonna do crap!'
                )

            display.update(mode=states.print_state(expected_state),
                           program=mode.program_name(),
                           temp_f=current_temp,
                           temp_c=current_temp_c)
        except Exception:
            LOG.exception('CRAP!!!! Stuff happened')