1 """Data representation for fitbit API responses."""
3 from collections.abc
import Mapping
4 from dataclasses
import dataclass
7 from .const
import CONF_CLOCK_FORMAT, CONF_MONITORED_RESOURCES, FitbitScope
12 """User profile from the Fitbit API response."""
15 """The ID representing the Fitbit user."""
18 """The name shown when the user's friends look at their Fitbit profile."""
21 """The locale defined in the user's Fitbit account settings."""
26 """Device from the Fitbit API response."""
32 """The product name of the device."""
35 """The battery level as a percentage."""
38 """Returns the battery level of the device."""
41 """The type of the device such as TRACKER or SCALE."""
46 """Information from the fitbit ConfigEntry data."""
48 clock_format: str |
None
49 monitored_resources: set[str] |
None
50 scopes: set[FitbitScope]
53 """Determine if entity is enabled by default."""
54 if self.monitored_resources
is not None:
55 return key
in self.monitored_resources
59 """Determine if an entity is allowed to be created."""
62 return scope
in self.scopes
66 """Parse the integration config entry into a FitbitConfig."""
68 clock_format = data.get(CONF_CLOCK_FORMAT)
74 monitored_resources = data.get(CONF_MONITORED_RESOURCES)
75 fitbit_scopes: set[FitbitScope] = set({})
76 if scopes := data[
"token"].
get(
"scope"):
77 fitbit_scopes = set({
FitbitScope(scope)
for scope
in scopes.split(
" ")})
78 return FitbitConfig(clock_format, monitored_resources, fitbit_scopes)
bool is_explicit_enable(self, str key)
bool is_allowed_resource(self, FitbitScope|None scope, str key)
web.Response get(self, web.Request request, str config_key)
FitbitConfig config_from_entry_data(Mapping[str, Any] data)