more failure catching and prints
This commit is contained in:
parent
4fdf91ece7
commit
9387dfbea9
@ -1,6 +1,6 @@
|
|||||||
name: "Fritz!Box Temperature Sync Dev"
|
name: "Fritz!Box Temperature Sync Dev"
|
||||||
description: "Sync Fritz!DECT thermostat temperatures with other sensors in Home Assistant"
|
description: "Sync Fritz!DECT thermostat temperatures with other sensors in Home Assistant"
|
||||||
version: "0.5.0"
|
version: "0.5.1"
|
||||||
startup: "application"
|
startup: "application"
|
||||||
stage: "stable"
|
stage: "stable"
|
||||||
slug: "fritz_temp_sync_dev"
|
slug: "fritz_temp_sync_dev"
|
||||||
|
@ -176,7 +176,12 @@ class FritzBox:
|
|||||||
|
|
||||||
name = name[0].string
|
name = name[0].string
|
||||||
id = int(button[0].button["value"])
|
id = int(button[0].button["value"])
|
||||||
|
print("Temperature raw:", temperature)
|
||||||
|
try:
|
||||||
temperature = float(temperature[0].string.split(" ")[0].replace(",", "."))
|
temperature = float(temperature[0].string.split(" ")[0].replace(",", "."))
|
||||||
|
except:
|
||||||
|
print("Error parsing temperature.")
|
||||||
|
return []
|
||||||
|
|
||||||
request_data = {
|
request_data = {
|
||||||
"device": id,
|
"device": id,
|
||||||
@ -186,6 +191,7 @@ class FritzBox:
|
|||||||
|
|
||||||
r = self.session.get(f"{self.url}/{self._endpoints['device_details']}", params=request_data,
|
r = self.session.get(f"{self.url}/{self._endpoints['device_details']}", params=request_data,
|
||||||
verify=self.verify_ssl)
|
verify=self.verify_ssl)
|
||||||
|
|
||||||
device_content_raw = BeautifulSoup(r.text, "html.parser")
|
device_content_raw = BeautifulSoup(r.text, "html.parser")
|
||||||
offset = float(device_content_raw.find("input", {"type": "hidden", "name": "Offset"})["value"])
|
offset = float(device_content_raw.find("input", {"type": "hidden", "name": "Offset"})["value"])
|
||||||
devices_raw.append({
|
devices_raw.append({
|
||||||
@ -303,13 +309,17 @@ class FritzBox:
|
|||||||
if device is None:
|
if device is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
offset_changed = False
|
||||||
if self.old_fb:
|
if self.old_fb:
|
||||||
new_offset = device["offset"] + real_temp - device["temperature"]
|
new_offset = device["offset"] + real_temp - device["temperature"]
|
||||||
logging.info(f"Update offset from {device['offset']} to {new_offset}")
|
offset_changed = new_offset != device["offset"]
|
||||||
|
logging.info(f"Update offset from {device['offset']} to {new_offset} (changed: {offset_changed}")
|
||||||
else:
|
else:
|
||||||
new_offset = device.get_offset() + real_temp - device.get_temperature()
|
new_offset = device.get_offset() + real_temp - device.get_temperature()
|
||||||
logging.info(f"Update offset from {device.get_offset()} to {new_offset}")
|
offset_changed = new_offset != device.get_offset()
|
||||||
|
logging.info(f"Update offset from {device.get_offset()} to {new_offset} (changed: {offset_changed}")
|
||||||
|
|
||||||
|
if offset_changed:
|
||||||
if self.old_fb:
|
if self.old_fb:
|
||||||
device["offset"] = new_offset
|
device["offset"] = new_offset
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user