2024-02-19 19:48:46 +00:00
|
|
|
"""Implementation of cloud module."""
|
2024-04-16 18:21:20 +00:00
|
|
|
|
2024-04-17 13:39:24 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2024-04-24 16:38:52 +00:00
|
|
|
from ...feature import Feature
|
2024-02-19 19:48:46 +00:00
|
|
|
from ..smartmodule import SmartModule
|
|
|
|
|
|
|
|
|
2024-05-11 18:28:18 +00:00
|
|
|
class Cloud(SmartModule):
|
2024-02-19 19:48:46 +00:00
|
|
|
"""Implementation of cloud module."""
|
|
|
|
|
|
|
|
QUERY_GETTER_NAME = "get_connect_cloud_state"
|
|
|
|
REQUIRED_COMPONENT = "cloud_connect"
|
2024-07-11 15:21:59 +00:00
|
|
|
MINIMUM_UPDATE_INTERVAL_SECS = 60
|
2024-02-19 19:48:46 +00:00
|
|
|
|
2024-09-28 18:14:31 +00:00
|
|
|
def _initialize_features(self):
|
|
|
|
"""Initialize features after the initial update."""
|
2024-02-19 19:48:46 +00:00
|
|
|
self._add_feature(
|
|
|
|
Feature(
|
2024-09-28 18:14:31 +00:00
|
|
|
self._device,
|
2024-05-07 09:13:35 +00:00
|
|
|
id="cloud_connection",
|
|
|
|
name="Cloud connection",
|
2024-02-19 19:48:46 +00:00
|
|
|
container=self,
|
|
|
|
attribute_getter="is_connected",
|
|
|
|
icon="mdi:cloud",
|
2024-04-24 16:38:52 +00:00
|
|
|
type=Feature.Type.BinarySensor,
|
2024-05-07 09:13:35 +00:00
|
|
|
category=Feature.Category.Info,
|
2024-02-19 19:48:46 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_connected(self):
|
|
|
|
"""Return True if device is connected to the cloud."""
|
2024-07-04 07:02:50 +00:00
|
|
|
if self._has_data_error():
|
2024-04-23 11:56:32 +00:00
|
|
|
return False
|
2024-02-19 19:48:46 +00:00
|
|
|
return self.data["status"] == 0
|