Skip to content

Commit 9a78d91

Browse files
committed
Change battery_state to true when the percentage is less than 15(%)
1 parent da05526 commit 9a78d91

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

plugwise/data.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ def _update_gw_devices(self) -> None:
6363

6464
device.update(data)
6565

66-
if mac_list and "battery_state" in device["binary_sensors"] and device["zigbee_mac_address"] in mac_list:
66+
if (
67+
mac_list
68+
and "battery_state" in device["binary_sensors"]
69+
and device["zigbee_mac_address"] in mac_list
70+
and device["sensors"]["battery"] < 15
71+
):
6772
device["binary_sensors"]["battery_state"] = True
6873

6974
self._update_for_cooling(device)

tests/data/adam/adam_plus_anna_new.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"sensors": {
7777
"temperature": 16.5,
7878
"setpoint": 18,
79-
"battery": 38
79+
"battery": 14
8080
},
8181
"temperature_offset": {
8282
"lower_bound": -2,

userdata/adam_plus_anna_new/core.domain_objects.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
<interval/>
138138
<battery_meter id='30ccaa3872354f179364e9533e136901'/>
139139
<period start_date="2023-12-22T13:59:02.810+01:00" end_date="2023-12-22T13:59:02.810+01:00">
140-
<measurement log_date="2023-12-22T13:59:02.810+01:00">0.38</measurement>
140+
<measurement log_date="2023-12-22T13:59:02.810+01:00">0.14</measurement>
141141
</period>
142142
</point_log>
143143
<point_log id='cf69d23b6ac742fdb8093dbc04e219fa'>

0 commit comments

Comments
 (0)