1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00

Add support for refreshing synology_dsm sensors (#35141)

* Add support for refreshing synology_dsm sensors

Now supports `home_assistant.update_entity` service

* Don't immediately update sensors on add

This fixes all sensors being forcefully refreshed when setup.
This commit is contained in:
Ron Heft 2020-05-03 19:07:14 -04:00 committed by GitHub
parent e7b9cecec9
commit 42750088b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,7 +61,7 @@ async def async_setup_entry(
for sensor_type in STORAGE_DISK_SENSORS
]
async_add_entities(sensors, True)
async_add_entities(sensors)
class SynoNasSensor(Entity):
@ -132,6 +132,10 @@ class SynoNasSensor(Entity):
"""No polling needed."""
return False
async def async_update(self):
"""Only used by the generic entity update service."""
await self._api.update()
async def async_added_to_hass(self):
"""Register state update callback."""
self._unsub_dispatcher = async_dispatcher_connect(