mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
parent
0762c7caef
commit
7937064fb7
@ -36,7 +36,3 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
|
|
||||||
class UpCloudBinarySensor(UpCloudServerEntity, BinarySensorDevice):
|
class UpCloudBinarySensor(UpCloudServerEntity, BinarySensorDevice):
|
||||||
"""Representation of an UpCloud server sensor."""
|
"""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):
|
class UpCloudSwitch(UpCloudServerEntity, SwitchDevice):
|
||||||
"""Representation of an UpCloud server switch."""
|
"""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):
|
def turn_on(self, **kwargs):
|
||||||
"""Start the server."""
|
"""Start the server."""
|
||||||
if self.state == STATE_OFF:
|
if self.state == STATE_OFF:
|
||||||
|
@ -12,7 +12,8 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_USERNAME, CONF_PASSWORD, CONF_SCAN_INTERVAL,
|
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
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import (
|
from homeassistant.helpers.dispatcher import (
|
||||||
async_dispatcher_connect, dispatcher_send)
|
async_dispatcher_connect, dispatcher_send)
|
||||||
@ -129,9 +130,10 @@ class UpCloudServerEntity(Entity):
|
|||||||
async_dispatcher_connect(
|
async_dispatcher_connect(
|
||||||
self.hass, SIGNAL_UPDATE_UPCLOUD, self._update_callback)
|
self.hass, SIGNAL_UPDATE_UPCLOUD, self._update_callback)
|
||||||
|
|
||||||
|
@callback
|
||||||
def _update_callback(self):
|
def _update_callback(self):
|
||||||
"""Call update method."""
|
"""Call update method."""
|
||||||
self.schedule_update_ha_state(True)
|
self.async_schedule_update_ha_state(True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
@ -142,9 +144,9 @@ class UpCloudServerEntity(Entity):
|
|||||||
def state(self):
|
def state(self):
|
||||||
"""Return state of the server."""
|
"""Return state of the server."""
|
||||||
try:
|
try:
|
||||||
return STATE_MAP.get(self.data.state, STATE_UNKNOWN)
|
return STATE_MAP.get(self.data.state)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return STATE_UNKNOWN
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user