mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Use entities instead of devices for nissan leaf (#63542)
This commit is contained in:
parent
397538fd1a
commit
9ef1033152
@ -29,13 +29,13 @@ def setup_platform(
|
|||||||
if discovery_info is None:
|
if discovery_info is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
devices: list[LeafEntity] = []
|
entities: list[LeafEntity] = []
|
||||||
for vin, datastore in hass.data[DATA_LEAF].items():
|
for vin, datastore in hass.data[DATA_LEAF].items():
|
||||||
_LOGGER.debug("Adding binary_sensors for vin=%s", vin)
|
_LOGGER.debug("Adding binary_sensors for vin=%s", vin)
|
||||||
devices.append(LeafPluggedInSensor(datastore))
|
entities.append(LeafPluggedInSensor(datastore))
|
||||||
devices.append(LeafChargingSensor(datastore))
|
entities.append(LeafChargingSensor(datastore))
|
||||||
|
|
||||||
add_entities(devices, True)
|
add_entities(entities, True)
|
||||||
|
|
||||||
|
|
||||||
class LeafPluggedInSensor(LeafEntity, BinarySensorEntity):
|
class LeafPluggedInSensor(LeafEntity, BinarySensorEntity):
|
||||||
|
@ -23,12 +23,12 @@ def setup_platform(
|
|||||||
if discovery_info is None:
|
if discovery_info is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
devices: list[LeafEntity] = []
|
entities: list[LeafEntity] = []
|
||||||
for vin, datastore in hass.data[DATA_LEAF].items():
|
for vin, datastore in hass.data[DATA_LEAF].items():
|
||||||
_LOGGER.debug("Adding button for vin=%s", vin)
|
_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):
|
class LeafChargingButton(LeafEntity, ButtonEntity):
|
||||||
|
@ -32,21 +32,21 @@ ICON_RANGE = "mdi:speedometer"
|
|||||||
def setup_platform(
|
def setup_platform(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
add_devices: AddEntitiesCallback,
|
add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Sensors setup."""
|
"""Sensors setup."""
|
||||||
if discovery_info is None:
|
if discovery_info is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
devices: list[LeafEntity] = []
|
entities: list[LeafEntity] = []
|
||||||
for vin, datastore in hass.data[DATA_LEAF].items():
|
for vin, datastore in hass.data[DATA_LEAF].items():
|
||||||
_LOGGER.debug("Adding sensors for vin=%s", vin)
|
_LOGGER.debug("Adding sensors for vin=%s", vin)
|
||||||
devices.append(LeafBatterySensor(datastore))
|
entities.append(LeafBatterySensor(datastore))
|
||||||
devices.append(LeafRangeSensor(datastore, True))
|
entities.append(LeafRangeSensor(datastore, True))
|
||||||
devices.append(LeafRangeSensor(datastore, False))
|
entities.append(LeafRangeSensor(datastore, False))
|
||||||
|
|
||||||
add_devices(devices, True)
|
add_entities(entities, True)
|
||||||
|
|
||||||
|
|
||||||
class LeafBatterySensor(LeafEntity, SensorEntity):
|
class LeafBatterySensor(LeafEntity, SensorEntity):
|
||||||
|
@ -20,19 +20,19 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
def setup_platform(
|
def setup_platform(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
add_devices: AddEntitiesCallback,
|
add_entities: AddEntitiesCallback,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Nissan Leaf switch platform setup."""
|
"""Nissan Leaf switch platform setup."""
|
||||||
if discovery_info is None:
|
if discovery_info is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
devices = []
|
entities: list[LeafEntity] = []
|
||||||
for vin, datastore in hass.data[DATA_LEAF].items():
|
for vin, datastore in hass.data[DATA_LEAF].items():
|
||||||
_LOGGER.debug("Adding switch for vin=%s", vin)
|
_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):
|
class LeafClimateSwitch(LeafEntity, ToggleEntity):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user