-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing sensor from IoTaWatt device causes errors #1
Comments
Same issue - can't figure out how to remove an old sensor without deleting the entire addon and reinstalling. |
Renaming an output causes havok as well |
Any ideas on how to if this? 🤷 Ideally, I would want to resolve this one before submitting it to the HA repo for inclusion. EDIT: It appears to be the logic on the API side. |
I fixed the issue on the API side and released a new version to PyPi Below is a trackback from the sensor code in my branch
|
Step 1 is to add a new @property
def available(self) -> bool:
"""Return if entity is available."""
return super().available and self._ent in self.coordinator.data["sensors"] |
That way it will be marked as unavailable and won't cause a key error. A more proper fix is to remove the sensor completely. You can do that by overriding from homeassistant.helpers import entity_registry
@callback
def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
if self._ent not in self.coordinator.data["sensors"]:
entity_registry.async_get(self.hass).async_remove(self.entity_id)
return
super()._handle_coordinator_update() |
@balloob Thank you for your insights! I will take a look. 😃 |
@balloob I tried adding an I wanted to set an entity to |
@balloob Sorry to flood you with messages! But the I can live with the removal of older data from Home Assistant when removing/renaming a sensor from the IoTaWatt web interface. |
When removing a sensor from the IoTaWatt webpage, Home Assistant tries to update the state of the removed sensor and results in the errors in the log to appear for every poll
The text was updated successfully, but these errors were encountered: