Beispiel #1
0
 def GET(self, **kwargs):
     zones = []
     for zone in CONFIG.active_zones:
         zones.append({'zone': zone.zone,
                       'name': zone.name})
     return {'environment': 'prod' if in_production() else 'dev',
             'active_zones': zones,
             'version': __version__}
Beispiel #2
0
    def __start_zone(self, zone_index):
        zone_info = CONFIG.active_zones[zone_index]
        activate_zone(zone_info.zone)

        interval = getattr(zone_info, "interval", self.__interval)
        logging.info('Running zone {0} for {1} min/sec.'.format(
            zone_info.zone, interval))
        return datetime.now(), timedelta(
            minutes=interval) if in_production() else timedelta(
                seconds=interval)
Beispiel #3
0
 def __schedule_job(self):
     self.__scheduler.clear()
     if in_production():
         for day in self.__days:
             job = Job(1, self.__scheduler)
             job.start_day = day.name.lower()
             job.unit = 'weeks'
             job.at(self.__start_time.strftime("%H:%M")).do(
                 self.__run_cycle)
     else:
         self.__scheduler.every(3).minutes.do(self.__run_cycle)
     logging.info('Next run scheduled for {0}.'.format(
         self.__scheduler.next_run))
Beispiel #4
0
 def run(self):
     state.single_zone_on()
     start_time = datetime.now()
     activate_zone(self.__zone)
     while not self.__stop.is_set():
         now = datetime.now()
         timediff = timedelta(
             minutes=self.__interval) if in_production() else timedelta(
                 seconds=self.__interval)
         if now - start_time > timediff:
             self.__stop.set()
         sleep(1)
     stop_sprinkler()
     state.run_off()
     logging.info('Manual run for zone {0} end.'.format(self.__zone))
Beispiel #5
0
# -*- coding: utf-8 -*-

from yasc.utils import in_production, state
from yasc.button_controller import ButtonController
from yasc.zone_controller import ZoneController
from yasc.mqtt_controller import MQTTController
from yasc.server import start_server
from yasc.local_controller import LocalController
import logging

# RPi imports not working
if in_production():
    from yasc.pi_controller import setup_pi, cleanup_pi, led_on
else:
    def setup_pi():
        logging.debug('Setting up PI.')

    def cleanup_pi():
        logging.debug('Cleaning up PI config.')

    def led_on(led):
        logging.debug('Led {0} on.'.format(led))
        pass


def main():

    zone_controller = None
    local_controller = None
    button_controller = None
    mqtt_controller = None
Beispiel #6
0
 def run(self):
     while not self.__stop.is_set():
         self.__mqtt_controller.send_available_state()
         sleep(300 if in_production() else 5)