Use entities instead of devices for nissan leaf (#63542)
This commit is contained in:
parent
397538fd1a
commit
9ef1033152
4 changed files with 17 additions and 17 deletions
|
@ -29,13 +29,13 @@ def setup_platform(
|
|||
if discovery_info is None:
|
||||
return
|
||||
|
||||
devices: list[LeafEntity] = []
|
||||
entities: list[LeafEntity] = []
|
||||
for vin, datastore in hass.data[DATA_LEAF].items():
|
||||
_LOGGER.debug("Adding binary_sensors for vin=%s", vin)
|
||||
devices.append(LeafPluggedInSensor(datastore))
|
||||
devices.append(LeafChargingSensor(datastore))
|
||||
entities.append(LeafPluggedInSensor(datastore))
|
||||
entities.append(LeafChargingSensor(datastore))
|
||||
|
||||
add_entities(devices, True)
|
||||
add_entities(entities, True)
|
||||
|
||||
|
||||
class LeafPluggedInSensor(LeafEntity, BinarySensorEntity):
|
||||
|
|
|
@ -23,12 +23,12 @@ def setup_platform(
|
|||
if discovery_info is None:
|
||||
return
|
||||
|
||||
devices: list[LeafEntity] = []
|
||||
entities: list[LeafEntity] = []
|
||||
for vin, datastore in hass.data[DATA_LEAF].items():
|
||||
_LOGGER.debug("Adding button for vin=%s", vin)
|
||||
devices.append(LeafChargingButton(datastore))
|
||||
entities.append(LeafChargingButton(datastore))
|
||||
|
||||
add_entities(devices, True)
|
||||
add_entities(entities, True)
|
||||
|
||||
|
||||
class LeafChargingButton(LeafEntity, ButtonEntity):
|
||||
|
|
|
@ -32,21 +32,21 @@ ICON_RANGE = "mdi:speedometer"
|
|||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_devices: AddEntitiesCallback,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Sensors setup."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
||||
devices: list[LeafEntity] = []
|
||||
entities: list[LeafEntity] = []
|
||||
for vin, datastore in hass.data[DATA_LEAF].items():
|
||||
_LOGGER.debug("Adding sensors for vin=%s", vin)
|
||||
devices.append(LeafBatterySensor(datastore))
|
||||
devices.append(LeafRangeSensor(datastore, True))
|
||||
devices.append(LeafRangeSensor(datastore, False))
|
||||
entities.append(LeafBatterySensor(datastore))
|
||||
entities.append(LeafRangeSensor(datastore, True))
|
||||
entities.append(LeafRangeSensor(datastore, False))
|
||||
|
||||
add_devices(devices, True)
|
||||
add_entities(entities, True)
|
||||
|
||||
|
||||
class LeafBatterySensor(LeafEntity, SensorEntity):
|
||||
|
|
|
@ -20,19 +20,19 @@ _LOGGER = logging.getLogger(__name__)
|
|||
def setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_devices: AddEntitiesCallback,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Nissan Leaf switch platform setup."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
|
||||
devices = []
|
||||
entities: list[LeafEntity] = []
|
||||
for vin, datastore in hass.data[DATA_LEAF].items():
|
||||
_LOGGER.debug("Adding switch for vin=%s", vin)
|
||||
devices.append(LeafClimateSwitch(datastore))
|
||||
entities.append(LeafClimateSwitch(datastore))
|
||||
|
||||
add_devices(devices, True)
|
||||
add_entities(entities, True)
|
||||
|
||||
|
||||
class LeafClimateSwitch(LeafEntity, ToggleEntity):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue