mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 14:45:09 +02:00
Create Tractive battery charging sensor if charging_state
is not None
(#96713)
Check if charging_state is available
This commit is contained in:
@@ -24,8 +24,6 @@ from .const import (
|
|||||||
)
|
)
|
||||||
from .entity import TractiveEntity
|
from .entity import TractiveEntity
|
||||||
|
|
||||||
TRACKERS_WITH_BUILTIN_BATTERY = ("TRNJA4", "TRAXL1")
|
|
||||||
|
|
||||||
|
|
||||||
class TractiveBinarySensor(TractiveEntity, BinarySensorEntity):
|
class TractiveBinarySensor(TractiveEntity, BinarySensorEntity):
|
||||||
"""Tractive sensor."""
|
"""Tractive sensor."""
|
||||||
@@ -90,7 +88,7 @@ async def async_setup_entry(
|
|||||||
entities = [
|
entities = [
|
||||||
TractiveBinarySensor(client.user_id, item, SENSOR_TYPE)
|
TractiveBinarySensor(client.user_id, item, SENSOR_TYPE)
|
||||||
for item in trackables
|
for item in trackables
|
||||||
if item.tracker_details["model_number"] in TRACKERS_WITH_BUILTIN_BATTERY
|
if item.tracker_details.get("charging_state") is not None
|
||||||
]
|
]
|
||||||
|
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
Reference in New Issue
Block a user