updating configuration

This commit is contained in:
monster
2019-01-30 22:03:39 +03:00
parent 5c9324e3b2
commit 0bb13e203b
26 changed files with 121 additions and 39 deletions
+1 -1
View File
@@ -2,6 +2,6 @@ ARG VERSION
FROM acockburn/appdaemon:${VERSION} FROM acockburn/appdaemon:${VERSION}
RUN pip3 install \ RUN pip3 install \
emp_mos_api \ emp_mos_api==0.10 \
sqlalchemy \ sqlalchemy \
mysqlclient mysqlclient
@@ -41,7 +41,7 @@ class Doorbell(hass.Hass):
def send_image(self): 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': 'Фото звонившего.'}} 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)
@@ -8,14 +8,3 @@ kitchen_led_controller:
topic: home/kitchen-led/kitchen-led/state/set topic: home/kitchen-led/kitchen-led/state/set
global_dependencies: global_dependencies:
- globals - 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
+1 -1
View File
@@ -38,7 +38,7 @@ class Battery(hass.Hass):
if "battery_level" in devices[device]["attributes"]: if "battery_level" in devices[device]["attributes"]:
battery = devices[device]["attributes"]["battery_level"] battery = devices[device]["attributes"]["battery_level"]
if battery != None: if battery != None:
if battery < self.args["threshold"]: if battery < self.args["threshold"] and battery != 0:
low.append(device) low.append(device)
values[device] = battery values[device] = battery
@@ -2,6 +2,7 @@ import appdaemon.plugins.hass.hassapi as hass
from datetime import timedelta from datetime import timedelta
import datetime import datetime
import globals import globals
import requests
# #
# App to monitor entity update time. # App to monitor entity update time.
@@ -41,3 +42,13 @@ class Watchdog(hass.Hass):
friendly_name = self.friendly_name(entity) friendly_name = self.friendly_name(entity)
message = "Датчик {} ({}) не обновлялся в течении {} секунд.".format(friendly_name, entity, self.args['timeout']) message = "Датчик {} ({}) не обновлялся в течении {} секунд.".format(friendly_name, entity, self.args['timeout'])
self.notify(message, name = "telegram") 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))
@@ -7,5 +7,8 @@ watchdog_sensor_power_active_power:
entity: sensor.power_active_power entity: sensor.power_active_power
update_interval: 60 update_interval: 60
timeout: 360 timeout: 360
reboot: True
host: !secret modbus_host
password: !secret modbus_admin_pass
global_dependencies: global_dependencies:
- globals - globals
@@ -1,3 +1,4 @@
################################# #################################
# MOS.RU DATA RETRIEVER # # MOS.RU DATA RETRIEVER #
################################# #################################
+20 -6
View File
@@ -17,6 +17,8 @@ import datetime
class AirFresher(hass.Hass): class AirFresher(hass.Hass):
timers = [] timers = []
fresh_times = 0 fresh_times = 0
fresh_every_mins = 10
last_fresh_date = None
def initialize(self): def initialize(self):
self.listen_state(self.light_change, 'group.bath_light') self.listen_state(self.light_change, 'group.bath_light')
@@ -27,20 +29,32 @@ class AirFresher(hass.Hass):
self.cancel_timers() self.cancel_timers()
if (old == "off" and new == "on"): if (old == "off" and new == "on"):
self.log('Start freshing timer.') if self.last_fresh_date != None:
self.fresh_times = 0 diff = (self.datetime()-self.last_fresh_date).seconds / 60 # * 24 * 60 * 60
newtime = self.datetime()+datetime.timedelta(minutes=5) if (diff < self.fresh_every_mins):
self.timers.append(self.run_every(self.timer_tick, newtime, 3*60)) 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: def start_timer(self) -> None:
self.fresh() 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: def cancel_timers(self) -> None:
for timer in self.timers: for timer in self.timers:
self.cancel_timer(timer) self.cancel_timer(timer)
timers = [] timers = []
def timer_tick(self, args) -> None:
self.fresh()
def fresh(self): def fresh(self):
self.log("current timer: {}".format(self.last_fresh_date))
self.fresh_times = self.fresh_times + 1 self.fresh_times = self.fresh_times + 1
if (self.fresh_times > 5): if (self.fresh_times > 5):
self.log('Fresh max times is reached. Canceling timer.') self.log('Fresh max times is reached. Canceling timer.')
+34
View File
@@ -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'])
@@ -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
Binary file not shown.
+5
View File
@@ -9,6 +9,11 @@ homeassistant:
customize_domain: !include customize_domain.yaml customize_domain: !include customize_domain.yaml
packages: !include_dir_named packages/ packages: !include_dir_named packages/
api:
alexa:
smart_home:
http: http:
api_password: !secret ha_password api_password: !secret ha_password
base_url: !secret base_url base_url: !secret base_url
@@ -3,5 +3,5 @@
- platform: homeassistant - platform: homeassistant
event: start event: start
action: action:
- delay: 00:00:30 # Wait 30 seconds - delay: 00:01:00 # Wait 30 seconds
- service: homekit.start - service: homekit.start
@@ -1,5 +1,5 @@
- platform: synology - platform: synology
url: !secret syno_url url: !secret syno_url
username: admin username: !secret syno_user
password: !secret syno_pass password: !secret syno_pass
verify_ssl: False verify_ssl: False
@@ -0,0 +1,2 @@
cover.curtain_158d0002b0c46a:
friendly_name: Шторы
@@ -30,7 +30,7 @@ cameras:
name: Камеры name: Камеры
icon: mdi:cctv icon: mdi:cctv
entities: entities:
- camera.entrance - camera.enterance
alarmclock: alarmclock:
view: yes view: yes
@@ -3,4 +3,4 @@ kitchen_light:
control: hidden control: hidden
entities: entities:
- light.kitchen - light.kitchen
#- switch.kitchen_mini_light - switch.kitchen_mini_light
@@ -9,6 +9,7 @@
- light.yeelight_white_34ce0087ff33 - light.yeelight_white_34ce0087ff33
- light.yeelight_white_f0b4290e5444 - light.yeelight_white_f0b4290e5444
- light.yeelight_white_f0b429a8f6df - light.yeelight_white_f0b429a8f6df
- cover.curtain_158d0002b0c46a
- switch.plug_158d0001104a0c - switch.plug_158d0001104a0c
- switch.plug_158d00010dd98d - switch.plug_158d00010dd98d
- climate.living_room - climate.living_room
@@ -5,6 +5,7 @@ filter:
- switch - switch
- light - light
- vacuum - vacuum
- cover
include_entities: include_entities:
- sensor.humidity_158d0001149b3c - sensor.humidity_158d0001149b3c
- sensor.humidity_158d000117d37a - sensor.humidity_158d000117d37a
@@ -1,7 +1,7 @@
- platform: mqtt - platform: mqtt
name: "balcony" name: "balcony"
state_topic: "stat/balcony_light/POWER" state_topic: "stat/BALCONYV2/POWER"
command_topic: "cmnd/balcony_light/POWER" command_topic: "cmnd/BALCONYV2/POWER"
payload_on: "ON" payload_on: "ON"
payload_off: "OFF" payload_off: "OFF"
optimistic: false optimistic: false
@@ -0,0 +1,6 @@
- platform: alexa
email: !secret amazon_mail
password: !secret amazon_pass
url: amazon.com
exclude_devices:
- "This Device"
@@ -1,7 +1,5 @@
- platform: mqtt - platform: broadlink
name: "kitchen_mini_light" host: 192.168.1.63
state_topic: "home/plug/kitchen-mini-light/status" mac: 'B4430DCB6C07'
command_topic: "home/plug/kitchen-mini-light/status/set" type: 'sp2'
payload_on: "on" friendly_name: 'kitchen_mini_light'
payload_off: "off"
retain: false
@@ -1,5 +1,5 @@
- platform: yandextts - platform: yandextts
api_key: 'd511d71c-6589-4d9b-a096-645271e1d1cc' api_key: !secret yandex_tts_key
language: 'ru-RU' language: 'ru-RU'
codec: mp3 codec: mp3
voice: oksana voice: oksana
Submodule hass/settings/custom_components added at 3987b4dd57
Binary file not shown.
+9 -1
View File
@@ -8,9 +8,10 @@ base_host: xxxxxxxxx
base_localname: xxxxxxxxx base_localname: xxxxxxxxx
modbus_host: xxxxxxxxx modbus_host: xxxxxxxxx
modbus_port: xxxxxxxxx modbus_port: xxxxxxxxx
modbus_admin_pass: xxxxxxxxx
mysensors_gateway_ip: xxxxxxxxx mysensors_gateway_ip: xxxxxxxxx
yandex_tts_key: xxxxxxxxx
################################### ###################################
# RECORDER SETTINGS # # RECORDER SETTINGS #
################################### ###################################
@@ -87,6 +88,7 @@ work_longitude: 1.0
# SYNOLOGY SETTINGS # # SYNOLOGY SETTINGS #
################################### ###################################
syno_url: xxxxxxxxx syno_url: xxxxxxxxx
syno_user: xxxxxxxxx
syno_pass: xxxxxxxxx syno_pass: xxxxxxxxx
################################### ###################################
@@ -120,3 +122,9 @@ mosru_pwd: xxxxxxxxx
mosru_token: xxxxxxxxx mosru_token: xxxxxxxxx
mosru_flat_id: xxxxxxxxx mosru_flat_id: xxxxxxxxx
mosru_paycode: xxxxxxxxx mosru_paycode: xxxxxxxxx
###################################
# Amazon Alexa #
###################################
amazon_mail: xxxxxxxxx
amazon_pass: xxxxxxxxx