updating configuration

This commit is contained in:
Your Name
2019-11-17 09:59:10 +03:00
parent cf8737292d
commit 3b5104a10d
22 changed files with 201 additions and 94 deletions
@@ -34,6 +34,10 @@ class Purifier(hass.Hass):
self.listen_event_handle_list.append(self.listen_state(self.state_change, self.args['entity'], attribute='illuminance'))
def state_change(self, entity, attribute, old, new, kwargs):
presence_state = self.get_state(self.args['ha_panel'])
if presence_state != "disarmed":
# self.log('Nobody home, ignoring illuminance changes.')
return
self.log("{} changed from {} to {}".format(attribute, old, new))
if old > 0 and new == 0 and self.time_is_between(self.datetime(), self.args["on_time"], self.args["off_time"]):
self.night_mode()
@@ -61,7 +65,7 @@ class Purifier(hass.Hass):
self.call_service("fan/set_speed", entity_id = self.args['entity'], speed='favorite')
self.call_service("fan/xiaomi_miio_set_favorite_level", entity_id = self.args['entity'], level=self.away_fan_speed)
self.call_service("fan/xiaomi_miio_set_led_on", entity_id = self.args['entity'])
self.call_service("fan/xiaomi_miio_set_buzzer_on", entity_id = self.args['entity'])
# self.call_service("fan/xiaomi_miio_set_buzzer_on", entity_id = self.args['entity'])
def auto_mode(self):
self.mode='auto'
@@ -69,7 +73,7 @@ class Purifier(hass.Hass):
if 'entity' in self.args:
self.call_service("fan/set_speed", entity_id = self.args['entity'], speed='auto')
self.call_service("fan/xiaomi_miio_set_led_on", entity_id = self.args['entity'])
self.call_service("fan/xiaomi_miio_set_buzzer_on", entity_id = self.args['entity'])
# self.call_service("fan/xiaomi_miio_set_buzzer_on", entity_id = self.args['entity'])
def night_mode(self):
self.mode='night'
@@ -4,5 +4,6 @@ purifier_timer:
on_time: "06:45:00"
off_time: "23:00:00"
entity: fan.xiaomi_miio_device
ha_panel: alarm_control_panel.ha_alarm
global_dependencies:
- globals
@@ -28,10 +28,13 @@ class IntercomSwitch(hass.Hass):
entity_id = self.args['entity_id']
self.log("Somebody come home, turn on {}".format(entity_id))
self.turn_on(entity_id)
self.notify("Кто-то вернулся домой, включаю домофон.", name = self.args['notify'])
def leave_event(self, event_id, event_args, kwargs):
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
return
entity_id = self.args['entity_id']
self.log("All persons leave home, turn off {}".format(entity_id))
self.turn_off(entity_id)
self.turn_off(entity_id)
self.notify("Все ушли из дома, выключаю домофон", name = self.args['notify'])
@@ -4,6 +4,7 @@
intercom_auto_open:
module: intercom_switch
class: IntercomSwitch
notify: telegram_monster
entity_id: switch.domofon_mode
arrive_event: homekit_home_arrive
leave_event: homekit_home_leave
@@ -35,8 +35,6 @@ class WorkTime(hass.Hass):
self.run_timer()
def arrive_event(self, event_id, event_args, kwargs):
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
return
if self.arrive_time != None:
self.log('You have already arrived to the work today at {}'.format(self.arrive_time))
self.run_timer()
@@ -49,6 +47,9 @@ class WorkTime(hass.Hass):
self.run_timer()
self.log("Monster has arrived to work at {}, work till {}, will notify at {}.".format(self.arrive_time, self.leave_time, self.notify_time))
self.timers.append(self.run_every(self.timer_tick, self.notify_time, self.notify_every_seconds))
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
return
self.notify("Добро пожаловать в офис. Сегодня работаешь до {}.".format(self.format_time(self.leave_time)), name = self.args['notify'])
def run_timer(self):
@@ -60,8 +61,6 @@ class WorkTime(hass.Hass):
self.timers.append(self.run_every(self.timer_tick, timer_start, self.notify_every_seconds))
def leave_event(self, event_id, event_args, kwargs):
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
return
if self.arrive_time == None:
return
self.cancel_timers()
@@ -78,14 +77,17 @@ class WorkTime(hass.Hass):
else:
self.log("Monster leave work at {} - {}".format(self.arrive_time, self.datetime))
message = "Рабочий день окончен ({}-{}). Приятной дороги домой.{}".format(self.format_time(self.arrive_time), self.format_time(self.datetime()), travelTime)
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
return
self.notify(message, name = self.args['notify'])
# self.reset_timer_tick(None)
def timer_tick(self, args) -> None:
self.log('timer tick')
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
if self.notify_time == None or self.datetime()<self.notify_time:
return
if self.datetime()<self.notify_time:
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
return
message = "Ты пришел на работу в {}, работаешь до {}. Пора домой!".format(self.format_time(self.arrive_time), self.format_time(self.leave_time))
self.notify(message, name = self.args['notify'])
@@ -0,0 +1,19 @@
import appdaemon.plugins.hass.hassapi as hass
#
# Helper for presence detection
#
# Args:
# ha_panel - alarm control panel entity (to arm and disarm).
#
# Release Notes
#
# Version 1.0:
# Initial Version
class Presence(hass.Hass):
def initialize(self):
self.log('started')
def function():
pass