示例#1
0
 def initialize(self):
     self.log("Starting beamer Service")
     wait.wait_available(self,["binary_sensor.dev25_button","light.dev59","binary_sensor.dev25_button1s"],False)
     self.listen_state(self.led_toggle,"binary_sensor.dev25_button",new="on", old="off")
     self.listen_state(self.led_toggle_bed,"binary_sensor.dev10_button",new="on", old="off")
     self.listen_state(self.main_toggle,"binary_sensor.dev25_button1s", new="on", old="off")
     self.listen_state(self.aw,"light.dev59", new="on")
 def initialize(self):
     self.log("Starting kitchenTable Service")
     wait.wait_available(self,
                         ["binary_sensor.dev44_gpio_13", "light.dev44_2"],
                         False)
     self.listen_state(self.couch_toggle, "binary_sensor.dev44_gpio_13")
     self.listen_state(self.table_toggle, "binary_sensor.dev44_button")
     self.listen_state(self.tower_toggle, "light.dev44")
    def initialize(self):
        self.log("Starting movieroom_vent Service")
        wait.wait_available(
            self, ["switch.dev60_countdown", "sensor.dev60_countdown_state"],
            False)

        self.ventilation_time = 10
        self.listen_state(self.countdown, "switch.dev60_countdown")
        self.set_state("sensor.dev60_countdown_state", state="0")
示例#4
0
    def initialize(self):
        self.log("Starting Connection Service")
        wait.wait_available(self, "sensor.dev1_update", True)

        for i in range(1, 160):
            if (i == 18):
                continue
            e = "sensor.dev" + str(i) + "_update"
            if (self.entity_exists(e)):
                self.listen_state(self.t, "sensor.dev" + str(i) + "_update")
示例#5
0
    def initialize(self):
        self.log("Starting Energy Service")
        wait.wait_available(
            self, ["sensor.dev37_em_tot_grid", "sensor.pv_power_int"], False)
        #self.listen_state(self.update, "input_boolean.clear_Energy")
        self.cost_kwh = 0.247  #0.2231 # 25.35
        self.cost_fix_month = 17.31  # 17.85 # 196.46 = 16.37
        self.payment_month = 115
        self.dbg = True
        self.update()
        runtime = datetime.time(23, 50, 0)
        self.run_daily(self.update, runtime)

        ############ smart power ###############
        self.dbg_sp = 0

        self.sp_net_lp = 0
        self.sp_on_delay_on_until = datetime.datetime.now()
        self.sp_on_delay_off_until = datetime.datetime.now()
        self.sp_safe_budget = 100
        self.sp_est_pwr = []  # estimated power
        self.sp_remaining = []  # min thst the device shall run
        self.sp_dev = []
        self.sp_timesensor = []
        self.sp_constrain = []
        self.sp_constrain_l = []
        self.sp_constrain_u = []
        self.sp_on_delay = []
        self.sp_off_delay = []

        self.sp_add(
            dev="switch.dev40_gpio_12", pwr=240
        )  # dehumidifier has a build in safety feature to way 3 min before start, removed, power impact small
        #sommer		self.sp_add(dev="switch.dev30_gpio_0",  pwr=600, time=180,timesensor="sensor.pump_time") # pool pump
        self.sp_add(dev="switch.dev41_gpio_4",
                    pwr=1000,
                    constrain="sensor.dev29_temperature",
                    lower=0,
                    upper=55)  # WW Heater 1
        self.sp_add(dev="switch.dev41_gpio_5",
                    pwr=500,
                    constrain="sensor.dev29_temperature",
                    lower=0,
                    upper=55)  # WW Heater 2
        self.sp_add(dev="switch.dev41_gpio_12",
                    pwr=500,
                    constrain="sensor.dev29_temperature",
                    lower=0,
                    upper=55)  # WW Heater 3
        #sommer extreme		self.sp_add(dev="switch.dev38_gpio_5",  pwr=2200, on_delay=90, off_delay=10) # pool heat will start approximatly 80 sec after flow

        self.run_daily(self.sp_reset, runtime)
        self.sp_time = datetime.datetime.now()
        self.listen_state(self.sp, "sensor.dev37_em_cur_fast")
示例#6
0
 def initialize(self):
     self.log("Starting Battery Service")
     wait.wait_available(self, "sensor", True)
     all = self.get_state("sensor")
     self.sensors = []
     self.threshold = 15
     for i in all:
         if (i[-8:] == "_battery"):
             #self.log("found battery device: "+i)
             self.sensors.append(i)
             self.listen_state(self.update, i)
     self.update()
    def initialize(self):
        self.log("Starting Motion Service")
        self.my_sensors = self.args["sensors"]
        wait.wait_available(self, self.my_sensors, False)
        self.listen_state(self.turn_light_off,
                          "sensor.bed_occupancy",
                          old="1",
                          new="2")

        for i in self.my_sensors:
            #self.log("Sensor: "+i)
            self.listen_state(self.motion, i)
        self.turn_light_off()
示例#8
0
 def initialize(self):
     self.log("Starting workshop2 Service")
     wait.wait_available(self, [
         "switch.dev28_gpio_4", "switch.dev28_countdown",
         "switch.dev28_countdown_l", "sensor.dev28_countdown_state"
     ], False)
     self.ventilation_time_s = 30
     self.ventilation_time_l = 8 * 60 - 1  # 8 std
     self.ventilation_time_l_duty = 0.1
     self.listen_state(self.vent, "switch.dev28_gpio_4")
     self.listen_state(self.countdown, "switch.dev28_countdown")
     self.listen_state(self.countdown, "switch.dev28_countdown_l")
     self.set_state("sensor.dev28_countdown_state", state="0")
示例#9
0
 def initialize(self):
     self.log("Starting Workshop Service")
     wait.wait_available(
         self,
         ["light.dev20", "light.dev28", "binary_sensor.dev20_button1s"],
         False)
     self.listen_state(self.group_toggle,
                       "binary_sensor.dev20_button",
                       new="on",
                       old="off")
     self.listen_state(self.vent_toggle,
                       "binary_sensor.dev20_button1s",
                       new="on",
                       old="off")
示例#10
0
    def initialize(self):
        self.log("Starting Entrance Service 2")
        wait.wait_available(self, [
            "binary_sensor.dev54_button", "binary_sensor.dev17_motion",
            "person.kolja_2", "person.caro_2", "proximity.caro_home",
            "proximity.kolja_home"
        ], False)

        try:
            os.makedirs('/tmp/cams')
        except:
            pass

        self.ring_cnt = [0, 0, 0]
        self.listen_state(self.ring, "binary_sensor.dev54_button",
                          new="on")  #klingel
        self.listen_state(self.backdoor,
                          "binary_sensor.dev17_motion",
                          new="on")  #klingel

        self.run_daily(self.six, time(6, 0, 0))
        self.run_daily(self.twentytwo, time(22, 0, 0))
        self.run_daily(self.twentythree, time(23, 0, 0))
        try:
            self.run_at_sunrise(self.sunrise, offset=30 * 60)
            self.run_at_sunset(self.sunset, offset=15 * 60)
        except:
            pass
        self.listen_state(self.caro_home,
                          "person.caro_2",
                          new="home",
                          duration=10 * 60,
                          arg1="Caro home")  # everyone is home for 10 min
        self.listen_state(self.kolja_home,
                          "person.kolja_2",
                          new="home",
                          duration=10 * 60,
                          arg1="Kolja home")  # everyone is home for 10 min
        self.listen_state(self.approaching, "proximity.caro_home")
        self.listen_state(self.approaching, "proximity.kolja_home")

        now = datetime.now()
        self.recording_start = [now, now]
        self.listen_state(
            self.rec_front_door,
            "binary_sensor.mymotiondetectorrule_cell_motion_detection")
        self.listen_state(
            self.rec_garden,
            "binary_sensor.mymotiondetectorrule_cell_motion_detection_2")
示例#11
0
    def initialize(self):
        self.log("Starting xiaomi_vac Service")
        self.run_daily(self.reset, datetime.time(0, 0, 0))
        self.mct = 20 * 60  # minimum clean time 20min
        if (wait.wait_available(self, [
                "binary_sensor.someone_is_home",
                "vacuum.xiaomi_vacuum_cleaner",
                "vacuum.xiaomi_vacuum_cleaner_2"
        ], False)):
            self.listen_state(self.presents,
                              "binary_sensor.someone_is_home")  # instant
            self.vacs = [
                "vacuum.xiaomi_vacuum_cleaner",
                "vacuum.xiaomi_vacuum_cleaner_2"
            ]
            self.vac_clean_interval = [2, 1]
            self.cleaning_started = []
            self.tct = []  # total cleaning time
            self.is_cleaning = []  # status

            for vac in self.vacs:
                self.listen_state(self.cleaning, vac)
                self.cleaning_started.append(time.time())
                self.tct.append(0)
                self.is_cleaning.append(False)
            self.reset()
示例#12
0
 def initialize(self):
     self.log("Starting louisa Service")
     wait.wait_available(self, [
         "binary_sensor.dev24_button1s", "binary_sensor.dev24_button",
         "light.dev55"
     ], False)
     self.listen_state(self.lampinions_toggle,
                       "binary_sensor.dev24_button1s",
                       new="on",
                       old="off")
     self.listen_state(self.main_toggle,
                       "binary_sensor.dev24_button2s",
                       new="on",
                       old="off")
     self.listen_state(self.tower_toggle,
                       "binary_sensor.dev24_button",
                       new="on",
                       old="off")
示例#13
0
 def initialize(self):
     self.log("Starting bedroom Service")
     wait.wait_available(self, [
         "binary_sensor.dev31_button", "binary_sensor.dev31_button1s",
         "binary_sensor.dev32_button1s", "binary_sensor.dev31_button3s",
         "binary_sensor.dev32_button3s", "sensor.dev26_5_hold",
         "sensor.dev26_5_hold", "binary_sensor.dev26_gpio_5", "light.dev32"
     ], False)
     self.listen_state(self.crip_toggle,
                       "binary_sensor.dev31_button",
                       new="on",
                       old="off")
     self.listen_state(self.bedlight_off,
                       "binary_sensor.dev31_button1s",
                       new="on",
                       old="off")
     self.listen_state(self.bedlight_off,
                       "binary_sensor.dev32_button1s",
                       new="on",
                       old="off")
     self.listen_state(self.bedlight_c_on,
                       "binary_sensor.dev31_button3s",
                       new="on",
                       old="off")
     self.listen_state(self.bedlight_k_toggle,
                       "binary_sensor.dev32_button",
                       new="on",
                       old="off")
     self.listen_state(self.bedlight_on,
                       "binary_sensor.dev32_button3s",
                       new="on",
                       old="off")
     self.listen_state(self.ventilation_toggle, "sensor.dev26_5_hold")
     self.listen_state(self.bedlight_toggle,
                       "binary_sensor.dev26_gpio_5",
                       new="on",
                       old="off")
     self.listen_state(self.main_toggle,
                       "binary_sensor.dev26_button",
                       new="on",
                       old="off")
     self.listen_state(self.mpc, "light.dev32", new="on")
     self.listen_state(self.mpc, "sensor.bed_occupancy", old="1", new="2")
示例#14
0
 def initialize(self):
     self.log("Starting Pi Service")
     wait.wait_available(self,"sensor.dev30_update",False)
     self.listen_state(self.fuse, "sensor.dev30_update")
示例#15
0
 def initialize(self):
     self.log("Starting carlo Service")
     wait.wait_available(self,["binary_sensor.dev23_button1s","light.dev23","light.dev33"],False)
     self.listen_state(self.main_toggle,"binary_sensor.dev23_button1s", new = "on", old="off")
     self.listen_state(self.tower_toggle,"binary_sensor.dev23_button", new = "on", old="off")
示例#16
0
 def initialize(self):
     self.log("Starting Adafruit Service")
     wait.wait_available(self, "sensor.adafruit", False)
     self.listen_state(self.start, "sensor.adafruit")