Skip to content

Add econet thermostat support and use getattr for sensors#45564

Merged
MartinHjelmare merged 14 commits into
home-assistant:devfrom
w1ll1am23:econet_thermostats_and_sensor_updates
Mar 25, 2021
Merged

Add econet thermostat support and use getattr for sensors#45564
MartinHjelmare merged 14 commits into
home-assistant:devfrom
w1ll1am23:econet_thermostats_and_sensor_updates

Conversation

@w1ll1am23
Copy link
Copy Markdown
Contributor

@w1ll1am23 w1ll1am23 commented Jan 26, 2021

Proposed change

Add support for EcoNet thermostats and their associated sensors

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

This also addresses a comment here #44427 about using getattr for sensor stuff

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link
Copy Markdown

Hey there @vangorra, mind taking a look at this pull request as its been labeled with an integration (econet) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

Comment thread homeassistant/components/econet/climate.py Outdated
@w1ll1am23
Copy link
Copy Markdown
Contributor Author

@MartinHjelmare would love if you can take a look. Made some updates you requested previously.

Copy link
Copy Markdown

@derekatkins derekatkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been running this code and it's been working well for me.
I don't know how to handle the Medium-Low and Medium-High fan speeds, so I don't have a suggestion.
My biggest issue with Econet isn't with this, but with the Econet API itself, which doesn't provide sufficient per-zone status data in a multi-zone HVAC system. For example, it wont tell you which zone is calling for heat/AC. But this isn't the integration's fault.

@MartinHjelmare MartinHjelmare changed the title Added econet thermostat support and use get attr for sensors Add econet thermostat support and use getattr for sensors Jan 26, 2021
Comment thread homeassistant/components/econet/binary_sensor.py Outdated
@derekatkins
Copy link
Copy Markdown

I take it back -- I wasn't running this code, I was running a different version. I changed to this version and now I'm getting errors during startup and none of the devices or entities show up. An example of the error:

2021-01-30 12:05:37 ERROR (MainThread) [homeassistant.components.climate] Error while setting up econet platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/econet/climate.py", line 67, in async_setup_entry
    for thermostat in equipment[EquipmentType.THERMOSTAT]
KeyError: <EquipmentType.THERMOSTAT: 2>

I should note that this is when running against 2021.1.5, not 2021.2.0beta, so it's possible that there are other missing things that this PR depends on?

@w1ll1am23
Copy link
Copy Markdown
Contributor Author

@derekatkins Should be fixed now.

@derekatkins
Copy link
Copy Markdown

@w1ll1am23 Thanks. Now it's getting further, but still no climate entities.

It tries to create a bunch of duplicate entities:

2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.main_running
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.main_screen_locked
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.main_beep_enabled
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.zone_3_running
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.zone_3_screen_locked
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.zone_3_beep_enabled
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.zone_4_running
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.zone_4_screen_locked
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.zone_4_beep_enabled
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.zone_2_running
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.zone_2_screen_locked
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.econet entity: binary_sensor.zone_2_beep_enabled
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.main_alert_count
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.main_wifi_signal
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.zone_3_alert_count
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.zone_3_wifi_signal
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.zone_4_alert_count
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.zone_4_wifi_signal
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.zone_2_alert_count
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.zone_2_wifi_signal
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Main_alert_count already exists - ignoring sensor.main_alert_count
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Main_wifi_signal already exists - ignoring sensor.main_wifi_signal
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Zone 3_alert_count already exists - ignoring sensor.zone_3_alert_count
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Zone 3_wifi_signal already exists - ignoring sensor.zone_3_wifi_signal
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Zone 4_alert_count already exists - ignoring sensor.zone_4_alert_count
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Zone 4_wifi_signal already exists - ignoring sensor.zone_4_wifi_signal
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Zone 2_alert_count already exists - ignoring sensor.zone_2_alert_count
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Zone 2_wifi_signal already exists - ignoring sensor.zone_2_wifi_signal
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.main_water_usage_today
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.zone_3_water_usage_today
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.zone_4_water_usage_today
2021-01-30 20:50:45 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.econet entity: sensor.zone_2_water_usage_today
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Main_water_usage_today already exists - ignoring sensor.main_water_usage_today
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Zone 3_water_usage_today already exists - ignoring sensor.zone_3_water_usage_today
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Zone 4_water_usage_today already exists - ignoring sensor.zone_4_water_usage_today
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Platform econet does not generate unique IDs. ID 013824955568805919_Zone 2_water_usage_today already exists - ignoring sensor.zone_2_water_usage_today

My guess here is that it is trying to create the entities both from water_heater and climate, even though I only have a climate (HVAC). And then it throws a bunch of errors:

2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.climate] Error adding entities for domain climate with platform econet
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 422, in _async_add_entity
    capabilities=entity.capability_attributes,
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 189, in capability_attributes
    self.hass, self.min_temp, self.temperature_unit, self.precision
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 275, in temperature_unit
    raise NotImplementedError()
NotImplementedError
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform econet
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 531, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/config/custom_components/econet/sensor.py", line 94, in state
    value = getattr(self._econet, SENSOR_NAMES_TO_ATTRIBUTES[self._device_name])
AttributeError: 'Thermostat' object has no attribute 'todays_water_usage'
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.climate] Error while setting up econet platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 207, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 422, in _async_add_entity
    capabilities=entity.capability_attributes,
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 189, in capability_attributes
    self.hass, self.min_temp, self.temperature_unit, self.precision
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 275, in temperature_unit
    raise NotImplementedError()
NotImplementedError
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up econet platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 207, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 531, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/config/custom_components/econet/sensor.py", line 94, in state
    value = getattr(self._econet, SENSOR_NAMES_TO_ATTRIBUTES[self._device_name])
AttributeError: 'Thermostat' object has no attribute 'todays_water_usage'
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.water_heater] Error adding entities for domain water_heater with platform econet
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 422, in _async_add_entity
    capabilities=entity.capability_attributes,
  File "/usr/src/homeassistant/homeassistant/components/water_heater/__init__.py", line 161, in capability_attributes
    data[ATTR_OPERATION_LIST] = self.operation_list
  File "/config/custom_components/econet/water_heater.py", line 105, in operation_list
    ha_mode = ECONET_STATE_TO_HA[mode]
KeyError: <ThermostatOperationMode.HEATING: 2>
2021-01-30 20:50:45 ERROR (MainThread) [homeassistant.components.water_heater] Error while setting up econet platform for water_heater
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 207, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 316, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 422, in _async_add_entity
    capabilities=entity.capability_attributes,
  File "/usr/src/homeassistant/homeassistant/components/water_heater/__init__.py", line 161, in capability_attributes
    data[ATTR_OPERATION_LIST] = self.operation_list
  File "/config/custom_components/econet/water_heater.py", line 105, in operation_list
    ha_mode = ECONET_STATE_TO_HA[mode]
KeyError: <ThermostatOperationMode.HEATING: 2>

@w1ll1am23 w1ll1am23 marked this pull request as draft January 31, 2021 02:49
@w1ll1am23
Copy link
Copy Markdown
Contributor Author

@derekatkins yeah, I'm not sure whats going on here. I pushed something else that should fix the climate entity from not showing up. I can't figure out why it is duplicating the sensors...

…et version and set thermostats to get push updates
@w1ll1am23
Copy link
Copy Markdown
Contributor Author

@derekatkins the duplication issue should be fixed with the latest push.

@derekatkins
Copy link
Copy Markdown

derekatkins commented Jan 31, 2021

Confirmed, duplication issue is fixed, no crashes/traces seen, and basic functionality tests pass (able to change setpoints in HA and they get reflected in the thermostat, and change setpoint in thermostat and change is reflected in HA). New sensors also appear to work. Thank you!

@w1ll1am23
Copy link
Copy Markdown
Contributor Author

@MartinHjelmare can you please review this?

@w1ll1am23 w1ll1am23 requested a review from frenck March 21, 2021 17:04
Comment thread homeassistant/components/econet/binary_sensor.py Outdated
Comment thread homeassistant/components/econet/climate.py Outdated
Comment thread homeassistant/components/econet/climate.py Outdated
Comment thread homeassistant/components/econet/climate.py Outdated
Comment thread homeassistant/components/econet/climate.py Outdated
Comment thread homeassistant/components/econet/climate.py Outdated
Comment thread homeassistant/components/econet/sensor.py Outdated
Comment thread homeassistant/components/econet/sensor.py Outdated
Comment thread homeassistant/components/econet/sensor.py Outdated
w1ll1am23 added 2 commits March 24, 2021 22:39
@w1ll1am23
Copy link
Copy Markdown
Contributor Author

@derekatkins can you test these latest changes?

Comment thread homeassistant/components/econet/binary_sensor.py Outdated
@derekatkins
Copy link
Copy Markdown

@derekatkins can you test these latest changes?

Yes, I'll update my installation shortly and let you know.

@derekatkins
Copy link
Copy Markdown

Hi @w1ll1am23
Just tried to restart and I get the following:

2021-03-25 08:15:36 INFO (SyncWorker_1) [homeassistant.util.package] Attempting install of pyeconet==0.1.4
2021-03-25 08:15:51 INFO (MainThread) [homeassistant.setup] Setting up econet
2021-03-25 08:15:51 INFO (MainThread) [homeassistant.setup] Setup of domain econet took 0.0 seconds
2021-03-25 08:15:53 ERROR (MainThread) [custom_components.econet] Config entry failed: 500
2021-03-25 08:15:53 WARNING (MainThread) [homeassistant.config_entries] Config entry for econet not ready yet. Retrying in 5 seconds
2021-03-25 08:16:00 ERROR (MainThread) [custom_components.econet] Config entry failed: 500
...

I have not tried to delete and re-configure...
I have not seen any other econet errors, either.

Comment thread homeassistant/components/econet/binary_sensor.py Outdated
Comment thread homeassistant/components/econet/binary_sensor.py Outdated
William Scanlon and others added 2 commits March 25, 2021 09:53
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
@derekatkins
Copy link
Copy Markdown

Hi. Just tested the current code and it's working for me. I have update the temps in both directions, and I see the sensors I should.
Only issue is that wifi signal isn't reported correctly, but that's not a new issue.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@MartinHjelmare MartinHjelmare merged commit 4f4a6fd into home-assistant:dev Mar 25, 2021
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants