Cleanup and improve Plugwise merges (#36406)
* Remove period from logging messages * Save indentation using guard clauses * Typo * Walk other files * Rewalk all files * Not cleanup, but adding indicatd missing measurements * Revert new sensors
This commit is contained in:
parent
08e85696c1
commit
48d1bc7c13
5 changed files with 79 additions and 75 deletions
|
@ -153,52 +153,53 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
**ENERGY_SENSOR_MAP,
|
||||
**MISC_SENSOR_MAP,
|
||||
}.items():
|
||||
if sensor in data:
|
||||
if data[sensor] is None:
|
||||
continue
|
||||
if data.get(sensor) is None:
|
||||
continue
|
||||
|
||||
if "power" in device_properties["types"]:
|
||||
model = None
|
||||
if "power" in device_properties["types"]:
|
||||
model = None
|
||||
|
||||
if "plug" in device_properties["types"]:
|
||||
model = "Metered Switch"
|
||||
if "plug" in device_properties["types"]:
|
||||
model = "Metered Switch"
|
||||
|
||||
entities.append(
|
||||
PwPowerSensor(
|
||||
api,
|
||||
coordinator,
|
||||
device_properties["name"],
|
||||
dev_id,
|
||||
sensor,
|
||||
sensor_type,
|
||||
model,
|
||||
)
|
||||
entities.append(
|
||||
PwPowerSensor(
|
||||
api,
|
||||
coordinator,
|
||||
device_properties["name"],
|
||||
dev_id,
|
||||
sensor,
|
||||
sensor_type,
|
||||
model,
|
||||
)
|
||||
else:
|
||||
entities.append(
|
||||
PwThermostatSensor(
|
||||
api,
|
||||
coordinator,
|
||||
device_properties["name"],
|
||||
dev_id,
|
||||
sensor,
|
||||
sensor_type,
|
||||
)
|
||||
)
|
||||
else:
|
||||
entities.append(
|
||||
PwThermostatSensor(
|
||||
api,
|
||||
coordinator,
|
||||
device_properties["name"],
|
||||
dev_id,
|
||||
sensor,
|
||||
sensor_type,
|
||||
)
|
||||
)
|
||||
|
||||
if single_thermostat is False:
|
||||
for state in INDICATE_ACTIVE_LOCAL_DEVICE:
|
||||
if state in data:
|
||||
entities.append(
|
||||
PwAuxDeviceSensor(
|
||||
api,
|
||||
coordinator,
|
||||
device_properties["name"],
|
||||
dev_id,
|
||||
DEVICE_STATE,
|
||||
)
|
||||
if state not in data:
|
||||
continue
|
||||
|
||||
entities.append(
|
||||
PwAuxDeviceSensor(
|
||||
api,
|
||||
coordinator,
|
||||
device_properties["name"],
|
||||
dev_id,
|
||||
DEVICE_STATE,
|
||||
)
|
||||
break
|
||||
)
|
||||
break
|
||||
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
@ -260,7 +261,7 @@ class PwThermostatSensor(SmileSensor, Entity):
|
|||
data = self._api.get_device_data(self._dev_id)
|
||||
|
||||
if not data:
|
||||
_LOGGER.error("Received no data for device %s.", self._entity_name)
|
||||
_LOGGER.error("Received no data for device %s", self._entity_name)
|
||||
self.async_write_ha_state()
|
||||
return
|
||||
|
||||
|
@ -297,7 +298,7 @@ class PwAuxDeviceSensor(SmileSensor, Entity):
|
|||
data = self._api.get_device_data(self._dev_id)
|
||||
|
||||
if not data:
|
||||
_LOGGER.error("Received no data for device %s.", self._entity_name)
|
||||
_LOGGER.error("Received no data for device %s", self._entity_name)
|
||||
self.async_write_ha_state()
|
||||
return
|
||||
|
||||
|
@ -341,7 +342,7 @@ class PwPowerSensor(SmileSensor, Entity):
|
|||
data = self._api.get_device_data(self._dev_id)
|
||||
|
||||
if not data:
|
||||
_LOGGER.error("Received no data for device %s.", self._entity_name)
|
||||
_LOGGER.error("Received no data for device %s", self._entity_name)
|
||||
self.async_write_ha_state()
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue