Skip to content

Commit

Permalink
Merge pull request #79 from mypal/test
Browse files Browse the repository at this point in the history
fix sensor link
  • Loading branch information
mypal authored Aug 12, 2024
2 parents 52e92ba + e78ba05 commit 1fa9ab6
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions custom_components/ds_air/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,20 @@ def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
self._climates = list(map(lambda state: state.alias, Service.get_aircons()))
sensors = hass.states.async_all("sensor")
self._sensors_temp = {
state.entity_id: f"{state.attributes.get(ATTR_FRIENDLY_NAME, state.entity_id)} ({state.entity_id})"
for state in sensors
if state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TEMPERATURE
None: 'None',
**{
state.entity_id: f"{state.attributes.get(ATTR_FRIENDLY_NAME, state.entity_id)} ({state.entity_id})"
for state in sensors
if state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TEMPERATURE
}
}
self._sensors_humi = {
state.entity_id: f"{state.attributes.get(ATTR_FRIENDLY_NAME, state.entity_id)} ({state.entity_id})"
for state in sensors
if state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.HUMIDITY
None: 'None',
**{
state.entity_id: f"{state.attributes.get(ATTR_FRIENDLY_NAME, state.entity_id)} ({state.entity_id})"
for state in sensors
if state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.HUMIDITY
}
}
self._len = len(self._climates)
self._cur = -1
Expand Down Expand Up @@ -186,7 +192,7 @@ async def async_step_bind_sensors(self, user_input: dict[str, Any] | None = None
return self.async_create_entry(title="", data={"link": self._config_data})
cur_climate: str = self._climates[self._cur]
cur_links = self.config_entry.options.get("link", [])
cur_link = next(link for link in cur_links if link["climate"] == cur_climate)
cur_link = next((link for link in cur_links if link["climate"] == cur_climate), None)
cur_sensor_temp = cur_link.get("sensor_temp") if cur_link else None
cur_sensor_humi = cur_link.get("sensor_humi") if cur_link else None
return self.async_show_form(
Expand Down

0 comments on commit 1fa9ab6

Please sign in to comment.