diff --git a/homeassistant/components/binary_sensor/upcloud.py b/homeassistant/components/binary_sensor/upcloud.py index dd76231ad75..868a2e8ddd0 100644 --- a/homeassistant/components/binary_sensor/upcloud.py +++ b/homeassistant/components/binary_sensor/upcloud.py @@ -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) diff --git a/homeassistant/components/switch/upcloud.py b/homeassistant/components/switch/upcloud.py index 32d47670429..5c3af45bede 100644 --- a/homeassistant/components/switch/upcloud.py +++ b/homeassistant/components/switch/upcloud.py @@ -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: diff --git a/homeassistant/components/upcloud.py b/homeassistant/components/upcloud.py index e653e55b93b..40e4ceffed8 100644 --- a/homeassistant/components/upcloud.py +++ b/homeassistant/components/upcloud.py @@ -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):