Revert changes to platforms using self.device (#16209)
* Revert tank_utility * Fix Soundtouch * Fix Plex * Fix Emby * Fix Radiotherm * Fix Juicenet * Fix Qwikswitch * Fix Xiaomi miio * Fix Nest * Fix Tellduslive * Fix KNX
This commit is contained in:
1 parent
289b1802fd
commit
5341785aae
28 files changed
+256
-237
No files matched your search
@@ -49,14 +49,14 @@ class JuicenetSensorDevice(JuicenetDevice, Entity):
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the device."""
|
||||
return '{} {}'.format(self._device.name(), self._name)
|
||||
return '{} {}'.format(self.device.name(), self._name)
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon of the sensor."""
|
||||
icon = None
|
||||
if self.type == 'status':
|
||||
status = self._device.getStatus()
|
||||
status = self.device.getStatus()
|
||||
if status == 'standby':
|
||||
icon = 'mdi:power-plug-off'
|
||||
elif status == 'plugged':
|
||||
@@ -87,19 +87,19 @@ class JuicenetSensorDevice(JuicenetDevice, Entity):
|
||||
"""Return the state."""
|
||||
state = None
|
||||
if self.type == 'status':
|
||||
state = self._device.getStatus()
|
||||
state = self.device.getStatus()
|
||||
elif self.type == 'temperature':
|
||||
state = self._device.getTemperature()
|
||||
state = self.device.getTemperature()
|
||||
elif self.type == 'voltage':
|
||||
state = self._device.getVoltage()
|
||||
state = self.device.getVoltage()
|
||||
elif self.type == 'amps':
|
||||
state = self._device.getAmps()
|
||||
state = self.device.getAmps()
|
||||
elif self.type == 'watts':
|
||||
state = self._device.getWatts()
|
||||
state = self.device.getWatts()
|
||||
elif self.type == 'charge_time':
|
||||
state = self._device.getChargeTime()
|
||||
state = self.device.getChargeTime()
|
||||
elif self.type == 'energy_added':
|
||||
state = self._device.getEnergyAdded()
|
||||
state = self.device.getEnergyAdded()
|
||||
else:
|
||||
state = 'Unknown'
|
||||
return state
|
||||
@@ -109,7 +109,7 @@ class JuicenetSensorDevice(JuicenetDevice, Entity):
|
||||
"""Return the state attributes."""
|
||||
attributes = {}
|
||||
if self.type == 'status':
|
||||
man_dev_id = self._device.id()
|
||||
man_dev_id = self.device.id()
|
||||
if man_dev_id:
|
||||
attributes["manufacturer_device_id"] = man_dev_id
|
||||
return attributes
|
||||
@@ -64,7 +64,7 @@ class KNXSensor(Entity):
|
||||
|
||||
def __init__(self, hass, device):
|
||||
"""Initialize of a KNX sensor."""
|
||||
self._device = device
|
||||
self.device = device
|
||||
self.hass = hass
|
||||
self.async_register_callbacks()
|
||||
|
||||
@@ -74,12 +74,12 @@ class KNXSensor(Entity):
|
||||
async def after_update_callback(device):
|
||||
"""Call after device was updated."""
|
||||
await self.async_update_ha_state()
|
||||
self._device.register_device_updated_cb(after_update_callback)
|
||||
self.device.register_device_updated_cb(after_update_callback)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the KNX device."""
|
||||
return self._device.name
|
||||
return self.device.name
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
@@ -94,12 +94,12 @@ class KNXSensor(Entity):
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self._device.resolve_state()
|
||||
return self.device.resolve_state()
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit this state is expressed in."""
|
||||
return self._device.unit_of_measurement()
|
||||
return self.device.unit_of_measurement()
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
||||
@@ -140,15 +140,15 @@ class NestBasicSensor(NestSensorDevice):
|
||||
self._unit = SENSOR_UNITS.get(self.variable)
|
||||
|
||||
if self.variable in VARIABLE_NAME_MAPPING:
|
||||
self._state = getattr(self._device,
|
||||
self._state = getattr(self.device,
|
||||
VARIABLE_NAME_MAPPING[self.variable])
|
||||
elif self.variable in PROTECT_SENSOR_TYPES \
|
||||
and self.variable != 'color_status':
|
||||
# keep backward compatibility
|
||||
state = getattr(self._device, self.variable)
|
||||
state = getattr(self.device, self.variable)
|
||||
self._state = state.capitalize() if state is not None else None
|
||||
else:
|
||||
self._state = getattr(self._device, self.variable)
|
||||
self._state = getattr(self.device, self.variable)
|
||||
|
||||
|
||||
class NestTempSensor(NestSensorDevice):
|
||||
@@ -166,12 +166,12 @@ class NestTempSensor(NestSensorDevice):
|
||||
|
||||
def update(self):
|
||||
"""Retrieve latest state."""
|
||||
if self._device.temperature_scale == 'C':
|
||||
if self.device.temperature_scale == 'C':
|
||||
self._unit = TEMP_CELSIUS
|
||||
else:
|
||||
self._unit = TEMP_FAHRENHEIT
|
||||
|
||||
temp = getattr(self._device, self.variable)
|
||||
temp = getattr(self.device, self.variable)
|
||||
if temp is None:
|
||||
self._state = None
|
||||
|
||||
|
||||
@@ -79,10 +79,15 @@ class TankUtilitySensor(Entity):
|
||||
self._token = token
|
||||
self._device = device
|
||||
self._state = STATE_UNKNOWN
|
||||
self._name = "Tank Utility " + self._device
|
||||
self._name = "Tank Utility " + self.device
|
||||
self._unit_of_measurement = SENSOR_UNIT_OF_MEASUREMENT
|
||||
self._attributes = {}
|
||||
|
||||
@property
|
||||
def device(self):
|
||||
"""Return the device identifier."""
|
||||
return self._device
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the device."""
|
||||
@@ -112,14 +117,14 @@ class TankUtilitySensor(Entity):
|
||||
from tank_utility import auth, device
|
||||
data = {}
|
||||
try:
|
||||
data = device.get_device_data(self._token, self._device)
|
||||
data = device.get_device_data(self._token, self.device)
|
||||
except requests.exceptions.HTTPError as http_error:
|
||||
if (http_error.response.status_code ==
|
||||
requests.codes.unauthorized): # pylint: disable=no-member
|
||||
_LOGGER.info("Getting new token")
|
||||
self._token = auth.get_token(self._email, self._password,
|
||||
force=True)
|
||||
data = device.get_device_data(self._token, self._device)
|
||||
data = device.get_device_data(self._token, self.device)
|
||||
else:
|
||||
raise http_error
|
||||
data.update(data.pop("device", {}))
|
||||
|
||||
@@ -67,7 +67,7 @@ class TelldusLiveSensor(TelldusLiveEntity):
|
||||
@property
|
||||
def _value(self):
|
||||
"""Return value of the sensor."""
|
||||
return self._device.value(*self._id[1:])
|
||||
return self.device.value(*self._id[1:])
|
||||
|
||||
@property
|
||||
def _value_as_temperature(self):
|
||||
|
||||
Reference in new issue
Block a user