Cleanup EZVIZ number entity ()

* EZVIZ - Cleanup number entity

* NL

* Fix naming
This commit is contained in:
Renier Moorcroft 2023-08-13 13:41:37 +02:00 committed by GitHub
parent 00c60151d4
commit a74d83de66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,7 +66,7 @@ async def async_setup_entry(
] ]
async_add_entities( async_add_entities(
EzvizSensor(coordinator, camera, value, entry.entry_id) EzvizNumber(coordinator, camera, value, entry.entry_id)
for camera in coordinator.data for camera in coordinator.data
for capibility, value in coordinator.data[camera]["supportExt"].items() for capibility, value in coordinator.data[camera]["supportExt"].items()
if capibility == NUMBER_TYPE.supported_ext if capibility == NUMBER_TYPE.supported_ext
@ -74,11 +74,9 @@ async def async_setup_entry(
) )
class EzvizSensor(EzvizBaseEntity, NumberEntity): class EzvizNumber(EzvizBaseEntity, NumberEntity):
"""Representation of a EZVIZ number entity.""" """Representation of a EZVIZ number entity."""
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
coordinator: EzvizDataUpdateCoordinator, coordinator: EzvizDataUpdateCoordinator,
@ -86,7 +84,7 @@ class EzvizSensor(EzvizBaseEntity, NumberEntity):
value: str, value: str,
config_entry_id: str, config_entry_id: str,
) -> None: ) -> None:
"""Initialize the sensor.""" """Initialize the entity."""
super().__init__(coordinator, serial) super().__init__(coordinator, serial)
self.sensitivity_type = 3 if value == "3" else 0 self.sensitivity_type = 3 if value == "3" else 0
self._attr_native_max_value = 100 if value == "3" else 6 self._attr_native_max_value = 100 if value == "3" else 6