Error fix
This commit is contained in:
@@ -22,6 +22,7 @@ class Battery(hass.Hass):
|
||||
#self.check_batteries({"force": 1})
|
||||
time = datetime.time(10, 0, 0)
|
||||
self.run_daily(self.check_batteries, time)
|
||||
# self.check_batteries(None)
|
||||
|
||||
def check_batteries(self, kwargs):
|
||||
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
|
||||
@@ -30,17 +31,20 @@ class Battery(hass.Hass):
|
||||
devices = self.get_state()
|
||||
values = {}
|
||||
low = []
|
||||
for device in devices:
|
||||
for deviceName in devices:
|
||||
device = devices[deviceName]
|
||||
if device == None:
|
||||
continue
|
||||
battery = None
|
||||
if "attributes" in devices[device]:
|
||||
if "battery" in devices[device]["attributes"]:
|
||||
battery = devices[device]["attributes"]["battery"]
|
||||
if "battery_level" in devices[device]["attributes"]:
|
||||
battery = devices[device]["attributes"]["battery_level"]
|
||||
if "attributes" in device:
|
||||
if "battery" in device["attributes"]:
|
||||
battery = device["attributes"]["battery"]
|
||||
if "battery_level" in device["attributes"]:
|
||||
battery = device["attributes"]["battery_level"]
|
||||
if battery != None:
|
||||
if battery < self.args["threshold"] and battery != 0:
|
||||
low.append(device)
|
||||
values[device] = battery
|
||||
low.append(deviceName)
|
||||
values[deviceName] = battery
|
||||
|
||||
message=""
|
||||
if low:
|
||||
|
||||
@@ -29,6 +29,7 @@ class WaterCountersAlarm(hass.Hass):
|
||||
time = datetime.time(10, 0, 0)
|
||||
self.run_daily(self.check_checkup_dates, time)
|
||||
self.run_daily(self.check_send_dates, time)
|
||||
# self.check_send_dates([])
|
||||
|
||||
def check_send_dates(self, kwargs):
|
||||
if 'constraint' in self.args and not self.constrain_input_boolean(self.args['constraint']):
|
||||
@@ -36,15 +37,19 @@ class WaterCountersAlarm(hass.Hass):
|
||||
devices = self.get_state()
|
||||
values = {}
|
||||
send_devices = []
|
||||
for device in devices:
|
||||
for deviceName in devices:
|
||||
device = devices[deviceName]
|
||||
if (device == None):
|
||||
continue
|
||||
|
||||
send_date = None
|
||||
if "attributes" in devices[device]:
|
||||
if "date" in devices[device]["attributes"]:
|
||||
send_date = devices[device]["attributes"]["date"]
|
||||
if "attributes" in device:
|
||||
if "date" in device["attributes"]:
|
||||
send_date = device["attributes"]["date"]
|
||||
if send_date != None:
|
||||
self.log('found device {} with send date {}'.format(device, send_date))
|
||||
self.log('found device {} with send date {}'.format(deviceName, send_date))
|
||||
if send_date == "":
|
||||
send_devices.append(device)
|
||||
send_devices.append(deviceName)
|
||||
else:
|
||||
send_date_date = None
|
||||
if '-' in send_date:
|
||||
@@ -52,8 +57,8 @@ class WaterCountersAlarm(hass.Hass):
|
||||
else:
|
||||
send_date_date = datetime.datetime.strptime(send_date, '%d.%m.%Y')
|
||||
if send_date_date < (datetime.datetime.now() - datetime.timedelta(days=self.send_threasold)):
|
||||
send_devices.append(device)
|
||||
values[device] = send_date
|
||||
send_devices.append(deviceName)
|
||||
values[deviceName] = send_date
|
||||
|
||||
message=""
|
||||
if send_devices:
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
power_history:
|
||||
module: db
|
||||
class: Db
|
||||
connectionstring: !secret mysql_url
|
||||
entity_id: sensor.power_total
|
||||
# power_history:
|
||||
# module: db
|
||||
# class: Db
|
||||
# connectionstring: !secret mysql_url
|
||||
# entity_id: sensor.power_total
|
||||
|
||||
debug: true
|
||||
global_dependencies:
|
||||
- automation
|
||||
# debug: true
|
||||
# global_dependencies:
|
||||
# - automation
|
||||
|
||||
|
||||
|
||||
counter_hot_history:
|
||||
module: db
|
||||
class: Db
|
||||
connectionstring: !secret mysql_url
|
||||
entity_id: sensor.counter_hot
|
||||
# counter_hot_history:
|
||||
# module: db
|
||||
# class: Db
|
||||
# connectionstring: !secret mysql_url
|
||||
# entity_id: sensor.counter_hot
|
||||
|
||||
debug: true
|
||||
global_dependencies:
|
||||
- automation
|
||||
# debug: true
|
||||
# global_dependencies:
|
||||
# - automation
|
||||
|
||||
counter_cold_history:
|
||||
module: db
|
||||
class: Db
|
||||
connectionstring: !secret mysql_url
|
||||
entity_id: sensor.counter_cold
|
||||
# counter_cold_history:
|
||||
# module: db
|
||||
# class: Db
|
||||
# connectionstring: !secret mysql_url
|
||||
# entity_id: sensor.counter_cold
|
||||
|
||||
debug: true
|
||||
global_dependencies:
|
||||
- automation
|
||||
# debug: true
|
||||
# global_dependencies:
|
||||
# - automation
|
||||
Reference in New Issue
Block a user