This commit is contained in:
Paulus Schoutsen committed 2019-07-31 12:25:30 -07:00
1 parent da05dfe708
commit 4de97abc3a
2676 files changed
+163166 -140084

No files matched your search

+18 -10
View File
@@ -7,17 +7,25 @@ from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice
import homeassistant.helpers.config_validation as cv
from . import (
ATTR_CREATED, ATTR_IPV4_ADDRESS, ATTR_IPV6_ADDRESS, ATTR_MEMORY,
ATTR_NODE_ID, ATTR_NODE_NAME, ATTR_REGION, ATTR_VCPUS, CONF_NODES,
DATA_LINODE)
ATTR_CREATED,
ATTR_IPV4_ADDRESS,
ATTR_IPV6_ADDRESS,
ATTR_MEMORY,
ATTR_NODE_ID,
ATTR_NODE_NAME,
ATTR_REGION,
ATTR_VCPUS,
CONF_NODES,
DATA_LINODE,
)
_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = 'Node'
DEFAULT_NAME = "Node"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_NODES): vol.All(cv.ensure_list, [cv.string]),
})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{vol.Required(CONF_NODES): vol.All(cv.ensure_list, [cv.string])}
)
def setup_platform(hass, config, add_entities, discovery_info=None):
@@ -65,12 +73,12 @@ class LinodeSwitch(SwitchDevice):
def turn_on(self, **kwargs):
"""Boot-up the Node."""
if self.data.status != 'running':
if self.data.status != "running":
self.data.boot()
def turn_off(self, **kwargs):
"""Shutdown the nodes."""
if self.data.status == 'running':
if self.data.status == "running":
self.data.shutdown()
def update(self):
@@ -81,7 +89,7 @@ class LinodeSwitch(SwitchDevice):
if node.id == self._node_id:
self.data = node
if self.data is not None:
self._state = self.data.status == 'running'
self._state = self.data.status == "running"
self._attrs = {
ATTR_CREATED: self.data.created,
ATTR_NODE_ID: self.data.id,