mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Use class properties in netatmo (#52705)
This commit is contained in:
parent
71b14b51b4
commit
cb0a7589ce
@ -330,7 +330,7 @@ class NetatmoCamera(NetatmoBase, Camera):
|
|||||||
async def _service_set_camera_light(self, **kwargs):
|
async def _service_set_camera_light(self, **kwargs):
|
||||||
"""Service to set light mode."""
|
"""Service to set light mode."""
|
||||||
mode = kwargs.get(ATTR_CAMERA_LIGHT_MODE)
|
mode = kwargs.get(ATTR_CAMERA_LIGHT_MODE)
|
||||||
_LOGGER.debug("Turn %s camera light for '%s'", mode, self._attr_name)
|
_LOGGER.debug("Turn %s camera light for '%s'", mode, self.name)
|
||||||
await self._data.async_set_state(
|
await self._data.async_set_state(
|
||||||
home_id=self._home_id,
|
home_id=self._home_id,
|
||||||
camera_id=self._id,
|
camera_id=self._id,
|
||||||
|
@ -126,7 +126,7 @@ class NetatmoLight(NetatmoBase, LightEntity):
|
|||||||
|
|
||||||
async def async_turn_on(self, **kwargs):
|
async def async_turn_on(self, **kwargs):
|
||||||
"""Turn camera floodlight on."""
|
"""Turn camera floodlight on."""
|
||||||
_LOGGER.debug("Turn camera '%s' on", self._attr_name)
|
_LOGGER.debug("Turn camera '%s' on", self.name)
|
||||||
await self._data.async_set_state(
|
await self._data.async_set_state(
|
||||||
home_id=self._home_id,
|
home_id=self._home_id,
|
||||||
camera_id=self._id,
|
camera_id=self._id,
|
||||||
@ -135,7 +135,7 @@ class NetatmoLight(NetatmoBase, LightEntity):
|
|||||||
|
|
||||||
async def async_turn_off(self, **kwargs):
|
async def async_turn_off(self, **kwargs):
|
||||||
"""Turn camera floodlight into auto mode."""
|
"""Turn camera floodlight into auto mode."""
|
||||||
_LOGGER.debug("Turn camera '%s' to auto mode", self._attr_name)
|
_LOGGER.debug("Turn camera '%s' to auto mode", self.name)
|
||||||
await self._data.async_set_state(
|
await self._data.async_set_state(
|
||||||
home_id=self._home_id,
|
home_id=self._home_id,
|
||||||
camera_id=self._id,
|
camera_id=self._id,
|
||||||
|
@ -366,13 +366,13 @@ class NetatmoSensor(NetatmoBase, SensorEntity):
|
|||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
"""Return entity availability."""
|
"""Return entity availability."""
|
||||||
return self._attr_state is not None
|
return self.state is not None
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_update_callback(self):
|
def async_update_callback(self):
|
||||||
"""Update the entity's state."""
|
"""Update the entity's state."""
|
||||||
if self._data is None:
|
if self._data is None:
|
||||||
if self._attr_state is None:
|
if self.state is None:
|
||||||
return
|
return
|
||||||
_LOGGER.warning("No data from update")
|
_LOGGER.warning("No data from update")
|
||||||
self._attr_state = None
|
self._attr_state = None
|
||||||
@ -383,7 +383,7 @@ class NetatmoSensor(NetatmoBase, SensorEntity):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if data is None:
|
if data is None:
|
||||||
if self._attr_state:
|
if self.state:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"No data found for %s - %s (%s)",
|
"No data found for %s - %s (%s)",
|
||||||
self.name,
|
self.name,
|
||||||
@ -410,7 +410,7 @@ class NetatmoSensor(NetatmoBase, SensorEntity):
|
|||||||
else:
|
else:
|
||||||
self._attr_state = state
|
self._attr_state = state
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if self._attr_state:
|
if self.state:
|
||||||
_LOGGER.debug("No %s data found for %s", self.type, self._device_name)
|
_LOGGER.debug("No %s data found for %s", self.type, self._device_name)
|
||||||
self._attr_state = None
|
self._attr_state = None
|
||||||
return
|
return
|
||||||
@ -614,7 +614,7 @@ class NetatmoPublicSensor(NetatmoBase, SensorEntity):
|
|||||||
data = self._data.get_latest_gust_strengths()
|
data = self._data.get_latest_gust_strengths()
|
||||||
|
|
||||||
if data is None:
|
if data is None:
|
||||||
if self._attr_state is None:
|
if self.state is None:
|
||||||
return
|
return
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"No station provides %s data in the area %s", self.type, self._area_name
|
"No station provides %s data in the area %s", self.type, self._area_name
|
||||||
@ -628,5 +628,5 @@ class NetatmoPublicSensor(NetatmoBase, SensorEntity):
|
|||||||
elif self._mode == "max":
|
elif self._mode == "max":
|
||||||
self._attr_state = max(values)
|
self._attr_state = max(values)
|
||||||
|
|
||||||
self._attr_available = self._attr_state is not None
|
self._attr_available = self.state is not None
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user