parent
0762c7caef
commit
7937064fb7
3 changed files with 6 additions and 12 deletions
|
@ -36,7 +36,3 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
|
||||
class UpCloudBinarySensor(UpCloudServerEntity, BinarySensorDevice):
|
||||
"""Representation of an UpCloud server sensor."""
|
||||
|
||||
def __init__(self, upcloud, uuid):
|
||||
"""Initialize a new UpCloud sensor."""
|
||||
UpCloudServerEntity.__init__(self, upcloud, uuid)
|
||||
|
|
|
@ -37,10 +37,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
class UpCloudSwitch(UpCloudServerEntity, SwitchDevice):
|
||||
"""Representation of an UpCloud server switch."""
|
||||
|
||||
def __init__(self, upcloud, uuid):
|
||||
"""Initialize a new UpCloud server switch."""
|
||||
UpCloudServerEntity.__init__(self, upcloud, uuid)
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Start the server."""
|
||||
if self.state == STATE_OFF:
|
||||
|
|
|
@ -12,7 +12,8 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.const import (
|
||||
CONF_USERNAME, CONF_PASSWORD, CONF_SCAN_INTERVAL,
|
||||
STATE_ON, STATE_OFF, STATE_PROBLEM, STATE_UNKNOWN)
|
||||
STATE_ON, STATE_OFF, STATE_PROBLEM)
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect, dispatcher_send)
|
||||
|
@ -129,9 +130,10 @@ class UpCloudServerEntity(Entity):
|
|||
async_dispatcher_connect(
|
||||
self.hass, SIGNAL_UPDATE_UPCLOUD, self._update_callback)
|
||||
|
||||
@callback
|
||||
def _update_callback(self):
|
||||
"""Call update method."""
|
||||
self.schedule_update_ha_state(True)
|
||||
self.async_schedule_update_ha_state(True)
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
@ -142,9 +144,9 @@ class UpCloudServerEntity(Entity):
|
|||
def state(self):
|
||||
"""Return state of the server."""
|
||||
try:
|
||||
return STATE_MAP.get(self.data.state, STATE_UNKNOWN)
|
||||
return STATE_MAP.get(self.data.state)
|
||||
except AttributeError:
|
||||
return STATE_UNKNOWN
|
||||
return None
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue