Ezviz NumberEntity 1st update only when enabled (#96587)

* Initial commit

* Initial commit

* Fix async_aded_to_hass
pull/96896/head
Renier Moorcroft 2023-07-19 10:56:11 +02:00 committed by GitHub
parent b53eae2846
commit e39187423f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -66,14 +66,11 @@ async def async_setup_entry(
]
async_add_entities(
[
EzvizSensor(coordinator, camera, value, entry.entry_id)
for camera in coordinator.data
for capibility, value in coordinator.data[camera]["supportExt"].items()
if capibility == NUMBER_TYPE.supported_ext
if value in NUMBER_TYPE.supported_ext_value
],
update_before_add=True,
EzvizSensor(coordinator, camera, value, entry.entry_id)
for camera in coordinator.data
for capibility, value in coordinator.data[camera]["supportExt"].items()
if capibility == NUMBER_TYPE.supported_ext
if value in NUMBER_TYPE.supported_ext_value
)
@ -98,6 +95,10 @@ class EzvizSensor(EzvizBaseEntity, NumberEntity):
self.config_entry_id = config_entry_id
self.sensor_value: int | None = None
async def async_added_to_hass(self) -> None:
"""Run when about to be added to hass."""
self.schedule_update_ha_state(True)
@property
def native_value(self) -> float | None:
"""Return the state of the entity."""