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
@@ -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
+12 -1
View File
@@ -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