1 """Data coordinator for the qnap integration."""
3 from __future__
import annotations
5 from datetime
import timedelta
9 from qnapstats
import QNAPStats
24 from .const
import DOMAIN
28 _LOGGER = logging.getLogger(__name__)
32 """Custom coordinator for the qnap integration."""
34 def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) ->
None:
35 """Initialize the qnap coordinator."""
36 super().
__init__(hass, _LOGGER, name=DOMAIN, update_interval=UPDATE_INTERVAL)
38 protocol =
"https" if config_entry.data[CONF_SSL]
else "http"
40 f
"{protocol}://{config_entry.data.get(CONF_HOST)}",
41 config_entry.data.get(CONF_PORT),
42 config_entry.data.get(CONF_USERNAME),
43 config_entry.data.get(CONF_PASSWORD),
44 verify_ssl=config_entry.data.get(CONF_VERIFY_SSL),
45 timeout=config_entry.data.get(CONF_TIMEOUT),
49 """Get the latest data from the Qnap API."""
51 "system_stats": self.
_api_api.get_system_stats(),
52 "system_health": self.
_api_api.get_system_health(),
53 "smart_drive_health": self.
_api_api.get_smart_disk_health(),
54 "volumes": self.
_api_api.get_volumes(),
55 "bandwidth": self.
_api_api.get_bandwidth(),
59 """Get the latest data from the Qnap API."""
60 return await self.
hasshass.async_add_executor_job(self.
_sync_update_sync_update)
dict[str, dict[str, Any]] _sync_update(self)
dict[str, dict[str, Any]] _async_update_data(self)
None __init__(self, HomeAssistant hass, ConfigEntry config_entry)