1 """Support for Linode."""
3 from datetime
import timedelta
7 import voluptuous
as vol
15 _LOGGER = logging.getLogger(__name__)
17 ATTR_CREATED =
"created"
18 ATTR_NODE_ID =
"node_id"
19 ATTR_NODE_NAME =
"node_name"
20 ATTR_IPV4_ADDRESS =
"ipv4_address"
21 ATTR_IPV6_ADDRESS =
"ipv6_address"
22 ATTR_MEMORY =
"memory"
23 ATTR_REGION =
"region"
28 DATA_LINODE =
"data_li"
29 LINODE_PLATFORMS = [Platform.BINARY_SENSOR, Platform.SWITCH]
34 CONFIG_SCHEMA = vol.Schema(
35 {DOMAIN: vol.Schema({vol.Required(CONF_ACCESS_TOKEN): cv.string})},
36 extra=vol.ALLOW_EXTRA,
40 def setup(hass: HomeAssistant, config: ConfigType) -> bool:
41 """Set up the Linode component."""
43 access_token = conf.get(CONF_ACCESS_TOKEN)
45 _linode =
Linode(access_token)
48 _LOGGER.debug(
"Linode Profile %s", _linode.manager.get_profile().username)
49 except linode.errors.ApiError
as _ex:
53 hass.data[DATA_LINODE] = _linode
59 """Handle all communication with the Linode API."""
62 """Initialize the Linode connection."""
68 """Get the status of a Linode Instance."""
72 all_nodes = self.
managermanager.linode.get_instances()
73 for node
in all_nodes:
74 if node_name == node.label:
76 except linode.errors.ApiError
as _ex:
81 @Throttle(MIN_TIME_BETWEEN_UPDATES)
83 """Use the data from Linode API."""
85 self.
datadata = self.
managermanager.linode.get_instances()
86 except linode.errors.ApiError
as _ex:
def __init__(self, access_token)
def get_node_id(self, node_name)
bool setup(HomeAssistant hass, ConfigType config)