diff --git a/appdaemon/docker/Dockerfile b/appdaemon/docker/Dockerfile index 1056435..24d45ce 100644 --- a/appdaemon/docker/Dockerfile +++ b/appdaemon/docker/Dockerfile @@ -2,6 +2,6 @@ ARG VERSION FROM acockburn/appdaemon:${VERSION} RUN pip3 install \ - emp_mos_api \ + emp_mos_api==0.10 \ sqlalchemy \ - mysqlclient \ No newline at end of file + mysqlclient diff --git a/appdaemon/settings/apps/doorbells/doorbell.py b/appdaemon/settings/apps/doorbells/doorbell.py index e3c07af..259d642 100644 --- a/appdaemon/settings/apps/doorbells/doorbell.py +++ b/appdaemon/settings/apps/doorbells/doorbell.py @@ -41,7 +41,7 @@ class Doorbell(hass.Hass): def send_image(self): - self.call_service("camera/snapshot", entity_id="camera.entrance", filename="/config/www/camera_image.jpg") + self.call_service("camera/snapshot", entity_id="camera.enterance", 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) diff --git a/appdaemon/settings/apps/light/kitchen_led_controller.yaml b/appdaemon/settings/apps/light/kitchen_led_controller.yaml index e7dcfc1..e7b22f5 100644 --- a/appdaemon/settings/apps/light/kitchen_led_controller.yaml +++ b/appdaemon/settings/apps/light/kitchen_led_controller.yaml @@ -8,14 +8,3 @@ kitchen_led_controller: topic: home/kitchen-led/kitchen-led/state/set global_dependencies: - globals - -################################# -# LIGHT BUTTONS # -################################# -kitchen_mini_light_controller: - module: kitchen_led_controller - class: KitchenLedController - watch_entity: light.kitchen - topic: home/plug/kitchen-mini-light/status/set - global_dependencies: - - globals diff --git a/appdaemon/settings/apps/notifiers/battery.py b/appdaemon/settings/apps/notifiers/battery.py index 435cfe0..a3113c5 100644 --- a/appdaemon/settings/apps/notifiers/battery.py +++ b/appdaemon/settings/apps/notifiers/battery.py @@ -38,7 +38,7 @@ class Battery(hass.Hass): if "battery_level" in devices[device]["attributes"]: battery = devices[device]["attributes"]["battery_level"] if battery != None: - if battery < self.args["threshold"]: + if battery < self.args["threshold"] and battery != 0: low.append(device) values[device] = battery diff --git a/appdaemon/settings/apps/notifiers/watchdog.py b/appdaemon/settings/apps/notifiers/watchdog.py index 7bf963b..7243027 100644 --- a/appdaemon/settings/apps/notifiers/watchdog.py +++ b/appdaemon/settings/apps/notifiers/watchdog.py @@ -2,6 +2,7 @@ import appdaemon.plugins.hass.hassapi as hass from datetime import timedelta import datetime import globals +import requests # # App to monitor entity update time. @@ -40,4 +41,14 @@ class Watchdog(hass.Hass): friendly_name = self.friendly_name(entity) message = "Датчик {} ({}) не обновлялся в течении {} секунд.".format(friendly_name, entity, self.args['timeout']) - self.notify(message, name = "telegram") \ No newline at end of file + self.notify(message, name = "telegram") + self.reboot_sensor() + + def reboot_sensor(self): + if 'reboot' in self.args and self.args['reboot']: + host = self.args['host'] + headers = {'Content-Type': 'application/json; charset=utf-8', 'Referer': 'http://{}/others.html'.format(host), 'X-Requested-With': 'XMLHttpRequest'} + data = 'msg={"CID":20003,"PL":{}}' + response = requests.post('http://{}/cmd'.format(host), headers=headers, data=data, auth=('admin', self.args['password'])) + json = response.json() + self.log("reboot status: {}".format(json)) diff --git a/appdaemon/settings/apps/notifiers/watchdog.yaml b/appdaemon/settings/apps/notifiers/watchdog.yaml index 06455b2..dba0375 100644 --- a/appdaemon/settings/apps/notifiers/watchdog.yaml +++ b/appdaemon/settings/apps/notifiers/watchdog.yaml @@ -7,5 +7,8 @@ watchdog_sensor_power_active_power: entity: sensor.power_active_power update_interval: 60 timeout: 360 + reboot: True + host: !secret modbus_host + password: !secret modbus_admin_pass global_dependencies: - - globals \ No newline at end of file + - globals diff --git a/appdaemon/settings/apps/sensors/mosru.yaml b/appdaemon/settings/apps/sensors/mosru.yaml index 7a4e35f..db49d9a 100644 --- a/appdaemon/settings/apps/sensors/mosru.yaml +++ b/appdaemon/settings/apps/sensors/mosru.yaml @@ -1,3 +1,4 @@ + ################################# # MOS.RU DATA RETRIEVER # ################################# diff --git a/appdaemon/settings/apps/timers/airfresher.py b/appdaemon/settings/apps/timers/airfresher.py index d8acfc7..69507a8 100644 --- a/appdaemon/settings/apps/timers/airfresher.py +++ b/appdaemon/settings/apps/timers/airfresher.py @@ -17,6 +17,8 @@ import datetime class AirFresher(hass.Hass): timers = [] fresh_times = 0 + fresh_every_mins = 10 + last_fresh_date = None def initialize(self): self.listen_state(self.light_change, 'group.bath_light') @@ -27,20 +29,32 @@ class AirFresher(hass.Hass): self.cancel_timers() if (old == "off" and new == "on"): - self.log('Start freshing timer.') - self.fresh_times = 0 - newtime = self.datetime()+datetime.timedelta(minutes=5) - self.timers.append(self.run_every(self.timer_tick, newtime, 3*60)) + if self.last_fresh_date != None: + diff = (self.datetime()-self.last_fresh_date).seconds / 60 # * 24 * 60 * 60 + if (diff < self.fresh_every_mins): + self.log("time passed from last fresh: {}".format(diff)) + self.log('Already dreshed in {} mins.'.format(self.fresh_every_mins)) + return + self.start_timer() - def timer_tick(self, args) -> None: - self.fresh() + def start_timer(self) -> None: + self.log('Start freshing timer.') + self.last_fresh_date = self.datetime() + self.fresh_times = 0 + newtime = self.datetime()+datetime.timedelta(seconds=5) + self.timers.append(self.run_every(self.timer_tick, newtime, 4*60)) def cancel_timers(self) -> None: for timer in self.timers: self.cancel_timer(timer) timers = [] + def timer_tick(self, args) -> None: + self.fresh() + def fresh(self): + self.log("current timer: {}".format(self.last_fresh_date)) + self.fresh_times = self.fresh_times + 1 if (self.fresh_times > 5): self.log('Fresh max times is reached. Canceling timer.') diff --git a/appdaemon/settings/apps/timers/curtain.py b/appdaemon/settings/apps/timers/curtain.py new file mode 100644 index 0000000..87238d4 --- /dev/null +++ b/appdaemon/settings/apps/timers/curtain.py @@ -0,0 +1,34 @@ +import appdaemon.plugins.hass.hassapi as hass +import globals +# +# Entity timer +# Turn on and off this entities +# +# Args: +# +# None +# +# Release Notes +# +# Version 1.0: +# Initial Version + +class Curtain(hass.Hass): + def initialize(self): + if not globals.check_args(self, ["on_time", "off_time"]): + return + on_time = self.parse_time(self.args["on_time"]) + off_time = self.parse_time(self.args["off_time"]) + + self.on_timer = self.run_daily(self.on_timer_tick, on_time) + self.off_timer = self.run_daily(self.off_timer_tick, off_time) + + def on_timer_tick(self, kwargs): + self.log('on_timer') + if 'entity' in self.args: + self.call_service("cover/open_cover", entity_id = self.args['entity']) + + def off_timer_tick(self, kwargs): + self.log('off_timer') + if 'entity' in self.args: + self.call_service("cover/close_cover", entity_id = self.args['entity']) diff --git a/appdaemon/settings/apps/timers/curtain.yaml b/appdaemon/settings/apps/timers/curtain.yaml new file mode 100644 index 0000000..628ae3e --- /dev/null +++ b/appdaemon/settings/apps/timers/curtain.yaml @@ -0,0 +1,8 @@ +curtain_timer: + module: curtain + class: Curtain + on_time: "07:45:00" + off_time: "21:00:00" + entity: cover.curtain_158d0002b0c46a + global_dependencies: + - globals \ No newline at end of file diff --git a/hass/settings/alexa_media.pickle b/hass/settings/alexa_media.pickle new file mode 100644 index 0000000..8938182 Binary files /dev/null and b/hass/settings/alexa_media.pickle differ diff --git a/hass/settings/configuration.yaml b/hass/settings/configuration.yaml index 499c5de..6602a90 100644 --- a/hass/settings/configuration.yaml +++ b/hass/settings/configuration.yaml @@ -9,6 +9,11 @@ homeassistant: customize_domain: !include customize_domain.yaml packages: !include_dir_named packages/ +api: + +alexa: + smart_home: + http: api_password: !secret ha_password base_url: !secret base_url diff --git a/hass/settings/configuration/automation/homekit.yaml b/hass/settings/configuration/automation/homekit.yaml index 3de2bb9..8cf43da 100644 --- a/hass/settings/configuration/automation/homekit.yaml +++ b/hass/settings/configuration/automation/homekit.yaml @@ -3,5 +3,5 @@ - platform: homeassistant event: start action: - - delay: 00:00:30 # Wait 30 seconds + - delay: 00:01:00 # Wait 30 seconds - service: homekit.start \ No newline at end of file diff --git a/hass/settings/configuration/camera/synology.yaml b/hass/settings/configuration/camera/synology.yaml index fe1822e..49597f4 100644 --- a/hass/settings/configuration/camera/synology.yaml +++ b/hass/settings/configuration/camera/synology.yaml @@ -1,5 +1,5 @@ - platform: synology url: !secret syno_url - username: admin + username: !secret syno_user password: !secret syno_pass verify_ssl: False \ No newline at end of file diff --git a/hass/settings/configuration/customize/cover.yaml b/hass/settings/configuration/customize/cover.yaml new file mode 100644 index 0000000..d25b6e4 --- /dev/null +++ b/hass/settings/configuration/customize/cover.yaml @@ -0,0 +1,2 @@ +cover.curtain_158d0002b0c46a: + friendly_name: Шторы \ No newline at end of file diff --git a/hass/settings/configuration/group/_views.yaml b/hass/settings/configuration/group/_views.yaml index 6075575..82bbd8f 100644 --- a/hass/settings/configuration/group/_views.yaml +++ b/hass/settings/configuration/group/_views.yaml @@ -30,7 +30,7 @@ cameras: name: Камеры icon: mdi:cctv entities: - - camera.entrance + - camera.enterance alarmclock: view: yes diff --git a/hass/settings/configuration/group/hidden/light/kitchen_light.yaml b/hass/settings/configuration/group/hidden/light/kitchen_light.yaml index b9eeca5..412c9f7 100644 --- a/hass/settings/configuration/group/hidden/light/kitchen_light.yaml +++ b/hass/settings/configuration/group/hidden/light/kitchen_light.yaml @@ -3,4 +3,4 @@ kitchen_light: control: hidden entities: - light.kitchen - #- switch.kitchen_mini_light \ No newline at end of file + - switch.kitchen_mini_light \ No newline at end of file diff --git a/hass/settings/configuration/group/home/mainroom.yaml b/hass/settings/configuration/group/home/mainroom.yaml index 2ba56ad..817ef03 100644 --- a/hass/settings/configuration/group/home/mainroom.yaml +++ b/hass/settings/configuration/group/home/mainroom.yaml @@ -9,6 +9,7 @@ - light.yeelight_white_34ce0087ff33 - light.yeelight_white_f0b4290e5444 - light.yeelight_white_f0b429a8f6df + - cover.curtain_158d0002b0c46a - switch.plug_158d0001104a0c - switch.plug_158d00010dd98d - climate.living_room diff --git a/hass/settings/configuration/homekit/homekit.yaml b/hass/settings/configuration/homekit/homekit.yaml index 71a6748..6b88eb6 100644 --- a/hass/settings/configuration/homekit/homekit.yaml +++ b/hass/settings/configuration/homekit/homekit.yaml @@ -5,6 +5,7 @@ filter: - switch - light - vacuum + - cover include_entities: - sensor.humidity_158d0001149b3c - sensor.humidity_158d000117d37a diff --git a/hass/settings/configuration/light/balcony.yaml b/hass/settings/configuration/light/balcony.yaml index 56db0f2..e3e64bc 100644 --- a/hass/settings/configuration/light/balcony.yaml +++ b/hass/settings/configuration/light/balcony.yaml @@ -1,7 +1,7 @@ - platform: mqtt name: "balcony" - state_topic: "stat/balcony_light/POWER" - command_topic: "cmnd/balcony_light/POWER" + state_topic: "stat/BALCONYV2/POWER" + command_topic: "cmnd/BALCONYV2/POWER" payload_on: "ON" payload_off: "OFF" optimistic: false diff --git a/hass/settings/configuration/media_player/alexa.yaml b/hass/settings/configuration/media_player/alexa.yaml new file mode 100644 index 0000000..0e95c9d --- /dev/null +++ b/hass/settings/configuration/media_player/alexa.yaml @@ -0,0 +1,6 @@ +- platform: alexa + email: !secret amazon_mail + password: !secret amazon_pass + url: amazon.com + exclude_devices: + - "This Device" \ No newline at end of file diff --git a/hass/settings/configuration/switch/kitchen_mini_light.yaml b/hass/settings/configuration/switch/kitchen_mini_light.yaml index 28f2f8f..7fae3e5 100644 --- a/hass/settings/configuration/switch/kitchen_mini_light.yaml +++ b/hass/settings/configuration/switch/kitchen_mini_light.yaml @@ -1,7 +1,5 @@ -- platform: mqtt - name: "kitchen_mini_light" - state_topic: "home/plug/kitchen-mini-light/status" - command_topic: "home/plug/kitchen-mini-light/status/set" - payload_on: "on" - payload_off: "off" - retain: false +- platform: broadlink + host: 192.168.1.63 + mac: 'B4430DCB6C07' + type: 'sp2' + friendly_name: 'kitchen_mini_light' \ No newline at end of file diff --git a/hass/settings/configuration/tts/yandex_tts.yaml b/hass/settings/configuration/tts/yandex_tts.yaml index 06ab348..dd6b0d4 100644 --- a/hass/settings/configuration/tts/yandex_tts.yaml +++ b/hass/settings/configuration/tts/yandex_tts.yaml @@ -1,5 +1,5 @@ - platform: yandextts - api_key: 'd511d71c-6589-4d9b-a096-645271e1d1cc' + api_key: !secret yandex_tts_key language: 'ru-RU' codec: mp3 voice: oksana \ No newline at end of file diff --git a/hass/settings/custom_components b/hass/settings/custom_components new file mode 160000 index 0000000..3987b4d --- /dev/null +++ b/hass/settings/custom_components @@ -0,0 +1 @@ +Subproject commit 3987b4dd57e13fba2e5f9938c1cf2f48e65447e9 diff --git a/hass/settings/mysensors1.pickle b/hass/settings/mysensors1.pickle index 0b6a084..48fc4f6 100644 Binary files a/hass/settings/mysensors1.pickle and b/hass/settings/mysensors1.pickle differ diff --git a/hass/settings/secrets.yaml.sample b/hass/settings/secrets.yaml.sample index 5e9a3df..a1deea4 100644 --- a/hass/settings/secrets.yaml.sample +++ b/hass/settings/secrets.yaml.sample @@ -8,9 +8,10 @@ base_host: xxxxxxxxx base_localname: xxxxxxxxx modbus_host: xxxxxxxxx modbus_port: xxxxxxxxx +modbus_admin_pass: xxxxxxxxx mysensors_gateway_ip: xxxxxxxxx - +yandex_tts_key: xxxxxxxxx ################################### # RECORDER SETTINGS # ################################### @@ -87,6 +88,7 @@ work_longitude: 1.0 # SYNOLOGY SETTINGS # ################################### syno_url: xxxxxxxxx +syno_user: xxxxxxxxx syno_pass: xxxxxxxxx ################################### @@ -119,4 +121,10 @@ mosru_login: xxxxxxxxx mosru_pwd: xxxxxxxxx mosru_token: xxxxxxxxx mosru_flat_id: xxxxxxxxx -mosru_paycode: xxxxxxxxx \ No newline at end of file +mosru_paycode: xxxxxxxxx + +################################### +# Amazon Alexa # +################################### +amazon_mail: xxxxxxxxx +amazon_pass: xxxxxxxxx \ No newline at end of file