updating configuration
This commit is contained in:
@@ -2,6 +2,6 @@ ARG VERSION
|
||||
FROM acockburn/appdaemon:${VERSION}
|
||||
|
||||
RUN pip3 install \
|
||||
emp_mos_api \
|
||||
emp_mos_api==0.10 \
|
||||
sqlalchemy \
|
||||
mysqlclient
|
||||
mysqlclient
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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")
|
||||
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
|
||||
update_interval: 60
|
||||
timeout: 360
|
||||
reboot: True
|
||||
host: !secret modbus_host
|
||||
password: !secret modbus_admin_pass
|
||||
global_dependencies:
|
||||
- globals
|
||||
- globals
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
#################################
|
||||
# MOS.RU DATA RETRIEVER #
|
||||
#################################
|
||||
|
||||
@@ -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.')
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user