mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
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
@ -58,10 +58,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
_LOGGER.error("Timeout while connecting to Smile")
|
_LOGGER.error("Timeout while connecting to Smile")
|
||||||
raise ConfigEntryNotReady
|
raise ConfigEntryNotReady
|
||||||
|
|
||||||
|
update_interval = timedelta(seconds=60)
|
||||||
if api.smile_type == "power":
|
if api.smile_type == "power":
|
||||||
update_interval = timedelta(seconds=10)
|
update_interval = timedelta(seconds=10)
|
||||||
else:
|
|
||||||
update_interval = timedelta(seconds=60)
|
|
||||||
|
|
||||||
async def async_update_data():
|
async def async_update_data():
|
||||||
"""Update data via API endpoint."""
|
"""Update data via API endpoint."""
|
||||||
@ -102,9 +101,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
sw_version=api.smile_version[0],
|
sw_version=api.smile_version[0],
|
||||||
)
|
)
|
||||||
|
|
||||||
platforms = ALL_PLATFORMS
|
|
||||||
|
|
||||||
single_master_thermostat = api.single_master_thermostat()
|
single_master_thermostat = api.single_master_thermostat()
|
||||||
|
|
||||||
|
platforms = ALL_PLATFORMS
|
||||||
if single_master_thermostat is None:
|
if single_master_thermostat is None:
|
||||||
platforms = SENSOR_PLATFORMS
|
platforms = SENSOR_PLATFORMS
|
||||||
|
|
||||||
@ -165,8 +164,6 @@ class SmileGateway(Entity):
|
|||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the entity, if any."""
|
"""Return the name of the entity, if any."""
|
||||||
if not self._name:
|
|
||||||
return None
|
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -26,10 +26,14 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
|
|
||||||
all_devices = api.get_all_devices()
|
all_devices = api.get_all_devices()
|
||||||
for dev_id, device_properties in all_devices.items():
|
for dev_id, device_properties in all_devices.items():
|
||||||
if device_properties["class"] == "heater_central":
|
if device_properties["class"] != "heater_central":
|
||||||
|
continue
|
||||||
|
|
||||||
data = api.get_device_data(dev_id)
|
data = api.get_device_data(dev_id)
|
||||||
for binary_sensor, dummy in BINARY_SENSOR_MAP.items():
|
for binary_sensor, dummy in BINARY_SENSOR_MAP.items():
|
||||||
if binary_sensor in data:
|
if binary_sensor not in data:
|
||||||
|
continue
|
||||||
|
|
||||||
entities.append(
|
entities.append(
|
||||||
PwBinarySensor(
|
PwBinarySensor(
|
||||||
api,
|
api,
|
||||||
@ -74,11 +78,14 @@ class PwBinarySensor(SmileSensor, BinarySensorEntity):
|
|||||||
data = self._api.get_device_data(self._dev_id)
|
data = self._api.get_device_data(self._dev_id)
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
_LOGGER.error("Received no data for device %s.", self._binary_sensor)
|
_LOGGER.error("Received no data for device %s", self._binary_sensor)
|
||||||
|
self.async_write_ha_state()
|
||||||
|
return
|
||||||
|
|
||||||
|
if self._binary_sensor not in data:
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._binary_sensor in data:
|
|
||||||
self._is_on = data[self._binary_sensor]
|
self._is_on = data[self._binary_sensor]
|
||||||
|
|
||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
|
@ -238,10 +238,9 @@ class PwThermostat(SmileGateway, ClimateEntity):
|
|||||||
self._schema_names = climate_data["available_schedules"]
|
self._schema_names = climate_data["available_schedules"]
|
||||||
if "selected_schedule" in climate_data:
|
if "selected_schedule" in climate_data:
|
||||||
self._selected_schema = climate_data["selected_schedule"]
|
self._selected_schema = climate_data["selected_schedule"]
|
||||||
|
self._schema_status = False
|
||||||
if self._selected_schema is not None:
|
if self._selected_schema is not None:
|
||||||
self._schema_status = True
|
self._schema_status = True
|
||||||
else:
|
|
||||||
self._schema_status = False
|
|
||||||
if "last_used" in climate_data:
|
if "last_used" in climate_data:
|
||||||
self._last_active_schema = climate_data["last_used"]
|
self._last_active_schema = climate_data["last_used"]
|
||||||
if "presets" in climate_data:
|
if "presets" in climate_data:
|
||||||
|
@ -153,8 +153,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
**ENERGY_SENSOR_MAP,
|
**ENERGY_SENSOR_MAP,
|
||||||
**MISC_SENSOR_MAP,
|
**MISC_SENSOR_MAP,
|
||||||
}.items():
|
}.items():
|
||||||
if sensor in data:
|
if data.get(sensor) is None:
|
||||||
if data[sensor] is None:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if "power" in device_properties["types"]:
|
if "power" in device_properties["types"]:
|
||||||
@ -188,7 +187,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
|
|
||||||
if single_thermostat is False:
|
if single_thermostat is False:
|
||||||
for state in INDICATE_ACTIVE_LOCAL_DEVICE:
|
for state in INDICATE_ACTIVE_LOCAL_DEVICE:
|
||||||
if state in data:
|
if state not in data:
|
||||||
|
continue
|
||||||
|
|
||||||
entities.append(
|
entities.append(
|
||||||
PwAuxDeviceSensor(
|
PwAuxDeviceSensor(
|
||||||
api,
|
api,
|
||||||
@ -260,7 +261,7 @@ class PwThermostatSensor(SmileSensor, Entity):
|
|||||||
data = self._api.get_device_data(self._dev_id)
|
data = self._api.get_device_data(self._dev_id)
|
||||||
|
|
||||||
if not data:
|
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()
|
self.async_write_ha_state()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -297,7 +298,7 @@ class PwAuxDeviceSensor(SmileSensor, Entity):
|
|||||||
data = self._api.get_device_data(self._dev_id)
|
data = self._api.get_device_data(self._dev_id)
|
||||||
|
|
||||||
if not data:
|
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()
|
self.async_write_ha_state()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -341,7 +342,7 @@ class PwPowerSensor(SmileSensor, Entity):
|
|||||||
data = self._api.get_device_data(self._dev_id)
|
data = self._api.get_device_data(self._dev_id)
|
||||||
|
|
||||||
if not data:
|
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()
|
self.async_write_ha_state()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class PwSwitch(SmileGateway, SwitchEntity):
|
|||||||
data = self._api.get_device_data(self._dev_id)
|
data = self._api.get_device_data(self._dev_id)
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
_LOGGER.error("Received no data for device %s.", self._name)
|
_LOGGER.error("Received no data for device %s", self._name)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user