Add Mysensors battery sensor (#100749)

* Move child related stuff to MySensorsChildEntity

* Dispatch signal for newly discovered MySensors node

* Create battery entity for each MySensors node

* Removed ATTR_BATTERY_LEVEL attribute from each node sensor

Attribute is redundant with newly introduced battery sensor entity

* Apply suggestions from code review

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Daniel Trnka 2023-09-24 22:50:13 +02:00 committed by GitHub
parent 6d624ecb46
commit 09729e8c46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 303 additions and 139 deletions

View file

@ -470,3 +470,19 @@ def text_node(gateway_nodes: dict[int, Sensor], text_node_state: dict) -> Sensor
nodes = update_gateway_nodes(gateway_nodes, text_node_state)
node = nodes[1]
return node
@pytest.fixture(name="battery_sensor_state", scope="session")
def battery_sensor_state_fixture() -> dict:
"""Load the battery sensor state."""
return load_nodes_state("battery_sensor_state.json")
@pytest.fixture
def battery_sensor(
gateway_nodes: dict[int, Sensor], battery_sensor_state: dict
) -> Sensor:
"""Load the battery sensor."""
nodes = update_gateway_nodes(gateway_nodes, deepcopy(battery_sensor_state))
node = nodes[1]
return node