Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add battery-state binary_sensors, translate battery-low message to a state-change #604

Merged
merged 50 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e6a6b0f
Add battery binary_sensor for devices with a battery
bouwew Aug 11, 2024
a5acdc7
Update device-asserts
bouwew Aug 11, 2024
ad85b79
Save updated fixtures
bouwew Aug 11, 2024
d2e6822
Find MAC address of device with low battery
bouwew Aug 11, 2024
d4e388d
Adam_plus_anna_new: add battery-low notification
bouwew Aug 11, 2024
e34da5b
Update corresponding test-json
bouwew Aug 11, 2024
506d916
Save updated fixtures
bouwew Aug 11, 2024
50eb35a
Full test output
bouwew Aug 11, 2024
957e382
Correct regex
bouwew Aug 11, 2024
f0cae50
Filter out battery-low notification
bouwew Aug 11, 2024
5536e66
Revert "Update corresponding test-json"
bouwew Aug 11, 2024
c213328
Ruff fix
bouwew Aug 11, 2024
c6ec50d
Save updated fixtures, again
bouwew Aug 11, 2024
8ac4731
Remove no longer valud comment
bouwew Aug 11, 2024
f79cfcf
Move battery-is-low detection to data.py
bouwew Aug 11, 2024
11511b4
Add debugging
bouwew Aug 11, 2024
7e44ddb
Import LOGGER
bouwew Aug 11, 2024
0f90d87
Fix typo
bouwew Aug 11, 2024
ba0678e
Add guarding
bouwew Aug 11, 2024
49b7d9e
Move import re
bouwew Aug 11, 2024
d3f74f3
Add walrus for msg
bouwew Aug 11, 2024
a5351a6
Optimize when to execute self._add_or_update_notifications(()
bouwew Aug 11, 2024
f17c33f
Avoid dictionary changed size during iteration
bouwew Aug 11, 2024
84e6ff6
Implement battery-binary_sensor updateing
bouwew Aug 11, 2024
4f0b396
Debug
bouwew Aug 11, 2024
cb7741f
Try
bouwew Aug 11, 2024
efdcb78
Save updated fixtures
bouwew Aug 11, 2024
b37f6af
Revert "Full test output"
bouwew Aug 11, 2024
356f02b
Remove debugging, rearrange code
bouwew Aug 12, 2024
a4d56b4
Put lines in correct order
bouwew Aug 12, 2024
0962607
Update/correct test-json files
bouwew Aug 12, 2024
b381838
Remove unneeded lines
bouwew Aug 12, 2024
4d858b1
Revert break-out of update_battery_binary_sensors() function
bouwew Aug 12, 2024
b6f7ace
Add battery to related classes in const.py
bouwew Aug 12, 2024
d453c8f
Unwrap, try fixing mypy errors
bouwew Aug 12, 2024
a47ece3
Rearrange adam test-cases
bouwew Aug 12, 2024
6a1c25d
Avoid double naming
bouwew Aug 12, 2024
11fe01f
Save updated fixtures
bouwew Aug 12, 2024
7c9cb42
Improve code
bouwew Aug 12, 2024
bc9601e
Fix 3 CodeSmells
bouwew Aug 12, 2024
a7c4ad3
Fix function-call also
bouwew Aug 13, 2024
b88d1ac
Implement as suggested
bouwew Aug 13, 2024
109af62
Add walrus as suggested
bouwew Aug 13, 2024
da05526
Update regex pattern
bouwew Aug 13, 2024
9a78d91
Change battery_state to true when the percentage is less than 15(%)
bouwew Aug 13, 2024
9486b6a
Save updated fixtures
bouwew Aug 13, 2024
f2276fc
Implement coderabbitai suggestions
bouwew Aug 13, 2024
3a19eae
Update CHANGELOG
bouwew Aug 13, 2024
ad1ac0d
Add different battery-level limits for different device-types
bouwew Aug 13, 2024
4efa175
Bump to v1.1.0a0 test-version
bouwew Aug 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion fixtures/adam_heatpump_cooling/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"Weekend",
"off"
],
"binary_sensors": {
"battery_state": false
},
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
Expand Down Expand Up @@ -521,6 +524,9 @@
"Weekend",
"off"
],
"binary_sensors": {
"battery_state": false
},
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
Expand Down Expand Up @@ -632,7 +638,7 @@
"cooling_present": true,
"gateway_id": "7d97fc3117784cfdafe347bcedcbbbcb",
"heater_id": "0ca13e8176204ca7bf6f09de59f81c83",
"item_count": 415,
"item_count": 417,
"notifications": {},
"reboot": true,
"smile_name": "Adam"
Expand Down
14 changes: 13 additions & 1 deletion fixtures/adam_jip/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"1346fbd8498d4dbcab7e18d51b771f3d": {
"active_preset": "no_frost",
"available": true,
"binary_sensors": {
"battery_state": false
},
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
Expand Down Expand Up @@ -97,6 +100,9 @@
"6f3e9d7084214c21b9dfa46f6eeb8700": {
"active_preset": "home",
"available": true,
"binary_sensors": {
"battery_state": false
},
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
Expand Down Expand Up @@ -152,6 +158,9 @@
"a6abc6a129ee499c88a4d420cc413b47": {
"active_preset": "home",
"available": true,
"binary_sensors": {
"battery_state": false
},
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
Expand Down Expand Up @@ -263,6 +272,9 @@
"f61f1a2535f54f52ad006a3d18e459ca": {
"active_preset": "home",
"available": true,
"binary_sensors": {
"battery_state": false
},
"control_state": "off",
"dev_class": "zone_thermometer",
"firmware": "2020-09-01T02:00:00+02:00",
Expand Down Expand Up @@ -298,7 +310,7 @@
"cooling_present": false,
"gateway_id": "b5c2386c6f6342669e50fe49dd05b188",
"heater_id": "e4684553153b44afbef2200885f379dc",
"item_count": 213,
"item_count": 217,
"notifications": {},
"reboot": true,
"smile_name": "Adam"
Expand Down
26 changes: 25 additions & 1 deletion fixtures/adam_multiple_devices_per_zone/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
},
"680423ff840043738f42cc7f1ff97a36": {
"available": true,
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermo_sensor",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -115,6 +118,9 @@
"CV Jessie",
"off"
],
"binary_sensors": {
"battery_state": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -199,6 +205,9 @@
},
"a2c3583e0a6349358998b760cea82d2a": {
"available": true,
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermo_sensor",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -255,6 +264,9 @@
"CV Jessie",
"off"
],
"binary_sensors": {
"battery_state": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-08-02T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -306,6 +318,9 @@
},
"d3da73bde12a47d5a6b8f9dad971f2ec": {
"available": true,
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermo_sensor",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -339,6 +354,9 @@
"CV Jessie",
"off"
],
"binary_sensors": {
"battery_state": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -379,6 +397,9 @@
"CV Jessie",
"off"
],
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermostatic_radiator_valve",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -421,6 +442,9 @@
"CV Jessie",
"off"
],
"binary_sensors": {
"battery_state": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -473,7 +497,7 @@
"cooling_present": false,
"gateway_id": "fe799307f1624099878210aa0b9f1475",
"heater_id": "90986d591dcd426cae3ec3e8111ff730",
"item_count": 315,
"item_count": 323,
"notifications": {
"af82e4ccf9c548528166d38e560662a4": {
"warning": "Node Plug (with MAC address 000D6F000D13CB01, in room 'n.a.') has been unreachable since 23:03 2020-01-18. Please check the connection and restart the device."
Expand Down
8 changes: 7 additions & 1 deletion fixtures/adam_plus_anna_new/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
},
"1772a4ea304041adb83f357b751341ff": {
"available": true,
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermo_sensor",
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -184,6 +187,9 @@
"Weekschema",
"off"
],
"binary_sensors": {
"battery_state": true
},
"control_state": "preheating",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
Expand Down Expand Up @@ -231,7 +237,7 @@
"cooling_present": false,
"gateway_id": "da224107914542988a88561b4452b0f6",
"heater_id": "056ee145a816487eaa69243c3280f8bf",
"item_count": 147,
"item_count": 149,
"notifications": {},
"reboot": true,
"smile_name": "Adam"
Expand Down
26 changes: 25 additions & 1 deletion fixtures/adam_zone_per_device/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
},
"680423ff840043738f42cc7f1ff97a36": {
"available": true,
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermo_sensor",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -115,6 +118,9 @@
"CV Jessie",
"off"
],
"binary_sensors": {
"battery_state": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -199,6 +205,9 @@
},
"a2c3583e0a6349358998b760cea82d2a": {
"available": true,
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermo_sensor",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -255,6 +264,9 @@
"CV Jessie",
"off"
],
"binary_sensors": {
"battery_state": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-08-02T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -306,6 +318,9 @@
},
"d3da73bde12a47d5a6b8f9dad971f2ec": {
"available": true,
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermo_sensor",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -339,6 +354,9 @@
"CV Jessie",
"off"
],
"binary_sensors": {
"battery_state": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -379,6 +397,9 @@
"CV Jessie",
"off"
],
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermostatic_radiator_valve",
"firmware": "2019-03-27T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -421,6 +442,9 @@
"CV Jessie",
"off"
],
"binary_sensors": {
"battery_state": false
},
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
"hardware": "255",
Expand Down Expand Up @@ -473,7 +497,7 @@
"cooling_present": false,
"gateway_id": "fe799307f1624099878210aa0b9f1475",
"heater_id": "90986d591dcd426cae3ec3e8111ff730",
"item_count": 315,
"item_count": 323,
"notifications": {
"af82e4ccf9c548528166d38e560662a4": {
"warning": "Node Plug (with MAC address 000D6F000D13CB01, in room 'n.a.') has been unreachable since 23:03 2020-01-18. Please check the connection and restart the device."
Expand Down
8 changes: 7 additions & 1 deletion fixtures/m_adam_cooling/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
},
"1772a4ea304041adb83f357b751341ff": {
"available": true,
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermo_sensor",
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -116,6 +119,9 @@
"Weekschema",
"off"
],
"binary_sensors": {
"battery_state": true
},
"control_state": "preheating",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
Expand Down Expand Up @@ -163,7 +169,7 @@
"cooling_present": true,
"gateway_id": "da224107914542988a88561b4452b0f6",
"heater_id": "056ee145a816487eaa69243c3280f8bf",
"item_count": 147,
"item_count": 149,
"notifications": {},
"reboot": true,
"smile_name": "Adam"
Expand Down
8 changes: 7 additions & 1 deletion fixtures/m_adam_heating/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
},
"1772a4ea304041adb83f357b751341ff": {
"available": true,
"binary_sensors": {
"battery_state": false
},
"dev_class": "thermo_sensor",
"firmware": "2020-11-04T01:00:00+01:00",
"hardware": "1",
Expand Down Expand Up @@ -115,6 +118,9 @@
"Weekschema",
"off"
],
"binary_sensors": {
"battery_state": true
},
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-10T02:00:00+02:00",
Expand Down Expand Up @@ -162,7 +168,7 @@
"cooling_present": false,
"gateway_id": "da224107914542988a88561b4452b0f6",
"heater_id": "056ee145a816487eaa69243c3280f8bf",
"item_count": 147,
"item_count": 149,
"notifications": {},
"reboot": true,
"smile_name": "Adam"
Expand Down
14 changes: 13 additions & 1 deletion fixtures/m_adam_jip/all_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"1346fbd8498d4dbcab7e18d51b771f3d": {
"active_preset": "no_frost",
"available": true,
"binary_sensors": {
"battery_state": false
},
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
Expand Down Expand Up @@ -97,6 +100,9 @@
"6f3e9d7084214c21b9dfa46f6eeb8700": {
"active_preset": "home",
"available": true,
"binary_sensors": {
"battery_state": false
},
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
Expand Down Expand Up @@ -152,6 +158,9 @@
"a6abc6a129ee499c88a4d420cc413b47": {
"active_preset": "home",
"available": true,
"binary_sensors": {
"battery_state": false
},
"control_state": "off",
"dev_class": "zone_thermostat",
"firmware": "2016-10-27T02:00:00+02:00",
Expand Down Expand Up @@ -263,6 +272,9 @@
"f61f1a2535f54f52ad006a3d18e459ca": {
"active_preset": "home",
"available": true,
"binary_sensors": {
"battery_state": false
},
"control_state": "off",
"dev_class": "zone_thermometer",
"firmware": "2020-09-01T02:00:00+02:00",
Expand Down Expand Up @@ -298,7 +310,7 @@
"cooling_present": false,
"gateway_id": "b5c2386c6f6342669e50fe49dd05b188",
"heater_id": "e4684553153b44afbef2200885f379dc",
"item_count": 213,
"item_count": 217,
"notifications": {},
"reboot": true,
"smile_name": "Adam"
Expand Down
Loading
Loading