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

@ -19,7 +19,7 @@ from homeassistant.util.color import rgb_hex_to_rgb_list
from .. import mysensors
from .const import MYSENSORS_DISCOVERY, DiscoveryInfo, SensorType
from .device import MySensorsEntity
from .device import MySensorsChildEntity
from .helpers import on_unload
@ -29,7 +29,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up this platform for a specific ConfigEntry(==Gateway)."""
device_class_map: dict[SensorType, type[MySensorsEntity]] = {
device_class_map: dict[SensorType, type[MySensorsChildEntity]] = {
"S_DIMMER": MySensorsLightDimmer,
"S_RGB_LIGHT": MySensorsLightRGB,
"S_RGBW_LIGHT": MySensorsLightRGBW,
@ -56,7 +56,7 @@ async def async_setup_entry(
)
class MySensorsLight(mysensors.device.MySensorsEntity, LightEntity):
class MySensorsLight(mysensors.device.MySensorsChildEntity, LightEntity):
"""Representation of a MySensors Light child node."""
def __init__(self, *args: Any) -> None: