diff --git a/appdaemon/settings/apps/climate/climate.py b/appdaemon/settings/apps/climate/climate.py index 64eb72f..441b622 100644 --- a/appdaemon/settings/apps/climate/climate.py +++ b/appdaemon/settings/apps/climate/climate.py @@ -6,6 +6,7 @@ class Climate(hass.Hass): ir_topic = "home/remote/rm2/code/set" split_state = "None" timer = None + fan_speed = "4" def initialize(self): self.listen_event_handle_list = [] @@ -57,7 +58,7 @@ class Climate(hass.Hass): code = "" self.log('mode: {}'.format(args['mode'])) remote = Remote() - code = remote.set_mode(args['mode'], "2", args['temp'], args['state']) + code = remote.set_mode(args['mode'], self.fan_speed, args['temp'], args['state']) code = code.decode("utf-8") self.call_service("mqtt/publish", topic = self.ir_topic, payload = code) diff --git a/appdaemon/settings/apps/doorbells/doorbell.py b/appdaemon/settings/apps/doorbells/doorbell.py index e7ce1f3..dbc6fbf 100644 --- a/appdaemon/settings/apps/doorbells/doorbell.py +++ b/appdaemon/settings/apps/doorbells/doorbell.py @@ -1,4 +1,5 @@ import appdaemon.plugins.hass.hassapi as hass +import os # # App to send notification when doorbell is ringing @@ -36,14 +37,15 @@ class Doorbell(hass.Hass): self.log("doorbell call") self.call_service("xiaomi_aqara/play_ringtone", gw_mac=self.gw_mac, ringtone_id=self.ringtone, ringtone_vol=100) self.notify("Звонок в дверь!!!", name = self.args['notify']) - # for x in range(3): - # self.send_image() - self.send_video() + result = self.send_video() - def send_video(self): + def send_video(self): file = '/config/www/doorbell_video.mp4' + if os.path.exists(file): + os.remove(file) + self.call_service("stream/record", stream_source=self.args['rtsp'], filename=file, duration=10) - self.timer = self.run_in(self.run_in_send_video, 12, file=file) + self.timer = self.run_in(self.run_in_send_video, 20, file=file) def run_in_send_video(self, args): extra_data = {'video': {'file': args['file'], 'caption': 'Видео звонившего.'}} @@ -53,4 +55,4 @@ class Doorbell(hass.Hass): def send_image(self): self.call_service("camera/snapshot", entity_id=self.args['camera'], filename="/config/www/camera_image.jpg") extra_data = {'photo': {'file':'/config/www/camera_image.jpg', 'capture': 'Фото звонившего.'}} - self.notify("Видео звонившего", name = self.args['notify'], data=extra_data) + self.notify("Фото звонившего", name = self.args['notify'], data=extra_data) diff --git a/appdaemon/settings/apps/scenes/alice_scenes.py b/appdaemon/settings/apps/scenes/alice_scenes.py new file mode 100644 index 0000000..5330943 --- /dev/null +++ b/appdaemon/settings/apps/scenes/alice_scenes.py @@ -0,0 +1,51 @@ +import appdaemon.plugins.hass.hassapi as hass +import globals +# +# Управление сценариями из алисы +# +# Args: +# +# None +# +# Release Notes +# +# Version 1.0: +# Initial Version + +class AliceScenes(hass.Hass): + listen_event_handle_list = [] + + def initialize(self): + if not globals.check_args(self, ['alice_prefix']): + return + devices = self.get_state() + for device in devices: + if not device.startswith(self.args['alice_prefix']): + continue + self.log("Listening for changes: {}".format(device)) + self.listen_event_handle_list.append(self.listen_state(self.alice_scene_trigger, device)) + + def alice_scene_trigger(self, entity, attribute, old, new, kwargs): + if new != 'on': + return + self.turn_off(entity) + + entity_name = entity.replace(self.args['alice_prefix'], "") + self.log('Alice triggered scene: {}'.format(entity_name)) + if (entity_name == "turn_off_light"): + self.turn_off_light() + if (entity_name == "night_mode"): + self.night_mode() + + def terminate(self): + if self.listen_event_handle_list != None: + for listen_event_handle in self.listen_event_handle_list: + self.cancel_listen_event(listen_event_handle) + + def turn_off_light(self): + self.turn_off('group.mainroom_light') + + def night_mode(self): + self.turn_off('switch.plug_158d0001104a0c') #tv + self.turn_off('group.all_lights') + self.call_service("cover/close_cover", entity_id = 'cover.curtain_158d0002b0c46a') \ No newline at end of file diff --git a/appdaemon/settings/apps/scenes/alice_scenes.yaml b/appdaemon/settings/apps/scenes/alice_scenes.yaml new file mode 100644 index 0000000..dc0e43f --- /dev/null +++ b/appdaemon/settings/apps/scenes/alice_scenes.yaml @@ -0,0 +1,6 @@ +alice_scenes: + module: alice_scenes + class: AliceScenes + alice_prefix: input_boolean.alice_ + global_dependencies: + - globals \ No newline at end of file diff --git a/appdaemon/settings/apps/sensors/toilet_presence.py b/appdaemon/settings/apps/sensors/toilet_presence.py index 2b867ef..be4d709 100644 --- a/appdaemon/settings/apps/sensors/toilet_presence.py +++ b/appdaemon/settings/apps/sensors/toilet_presence.py @@ -26,7 +26,7 @@ class ToiletPresence(hass.Hass): if 'sensor' not in self.args: self.error("Please provide sensor in config!") return - self.set_value("off") + self.set_value("off", 0) self.listen_state(self.distance_changed, self.args['sensor']) def distance_changed(self, entity, attribute, old, new, kwargs): @@ -37,22 +37,23 @@ class ToiletPresence(hass.Hass): self.timers.append(self.run_in(self.run_in_presense_off, self.presence_timeout)) self.log('re-setting timer for {}s.'.format(self.presence_timeout)) if (self.state != "on"): - self.set_value("on") + self.set_value("on", distance) def run_in_presense_off(self, args): - self.set_value("off") + self.set_value("off", 0) def timers_off(self): for timer in self.timers: self.cancel_timer(timer) - def set_value(self, state): + def set_value(self, state, distance): self.log('Toilet presense: {}'.format(state)) self.state = state entity_id = "sensor.toilet_presence" attributes = {} + attributes['distance'] = distance attributes['description'] = 'Created and updated from appdaemon ({})'.format(__name__) self.set_state(entity_id, state = state, attributes = attributes) \ No newline at end of file diff --git a/hass/settings/configuration/alice.yaml b/hass/settings/configuration/alice.yaml index 7e50a54..2417a7c 100644 --- a/hass/settings/configuration/alice.yaml +++ b/hass/settings/configuration/alice.yaml @@ -6,6 +6,10 @@ filter: - light - vacuum - cover + include_entities: + - input_boolean.alice_night_mode + - input_boolean.alice_turn_off_light + exclude_entities: - switch.plug_158d00020f3a29 - switch.plug_158d00026ea017 @@ -14,10 +18,10 @@ filter: - switch.domofon_mode - switch.domofon_open - light.gateway_light_f0b429aa1463 -# include_entities: -# - media_player.tv -# entity_config: + + # entity_config: + # input_boolean.alice_night_mode: + # room: SCENES + # switch.kitchen: # name: CUSTOM_NAME_FOR_YANDEX_SMART_HOME -# light.living_room: -# room: LIVING_ROOM diff --git a/hass/settings/configuration/input/input_boolean/alice_automation.yaml b/hass/settings/configuration/input/input_boolean/alice_automation.yaml new file mode 100644 index 0000000..d115c90 --- /dev/null +++ b/hass/settings/configuration/input/input_boolean/alice_automation.yaml @@ -0,0 +1,8 @@ +alice_night_mode: + name: Спокойной ночи + initial: off + +alice_turn_off_light: + name: Выключи свет + initial: off + diff --git a/hass/settings/custom_components/yandex_smart_home b/hass/settings/custom_components/yandex_smart_home index 19b012b..d9ef78d 160000 --- a/hass/settings/custom_components/yandex_smart_home +++ b/hass/settings/custom_components/yandex_smart_home @@ -1 +1 @@ -Subproject commit 19b012b1bbe2ace9ce33e57fb75d9720b22d5d1d +Subproject commit d9ef78dfc5de16d312e3d881ce2e99057fa242ff