natekspencer / hacs-pura

Home Assistant integration for Pura smart fragrance diffusers
MIT License
18 stars 1 forks source link

API call failed notification. But all works. #36

Closed sambeetm closed 9 months ago

sambeetm commented 9 months ago

The problem

I am getting below banner in the left lower every time select Off/Slot 1/Slot 2 or Turn On or Off the light. But, all seems to be working normally. More info is in the log.

failed to call service select/select_option.'name'
failed to call service light/turn_on.'name'
failed to call service light/turn_off.'name'

What version of Home Assistant Core are you running?

core-2023.11.3

What was the last working version of Home Assistant Core?

No response

Diagnostics information

config_entry-pura-1f647cfabee36f754ac72049e4ae95dc.json.txt

Anything in the logs that might be useful?

KeyError: 'name'
2023-12-01 18:13:34.850 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 233, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 389, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 172, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 469, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 743, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 784, in _async_generate_attributes
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 749, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 501, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pura/sensor.py", line 215, in native_value
    return self.entity_description.value_fn(self.get_device())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pura/sensor.py", line 59, in <lambda>
    value_fn=lambda data: data["bay_1"]["name"],
                          ~~~~~~~~~~~~~^^^^^^^^
KeyError: 'name'

Additional information

Integration ver. Release 0.1.17

natekspencer commented 9 months ago

Do you not have fragrances in your car diffusers at the moment? It looks like that's where it is causing the error. Because the data is pulled via a single endpoint for all devices, it's causing the error to show up on every interaction.

sambeetm commented 9 months ago

I have one Car diffuser with 26% fragrance and is working. This was the warranty replacement. The initial faulty one which I sent them back, does not show in my account(app). But, somehow being pulled by the API. May be I had not or could not remove from the app before sending them back.

natekspencer commented 9 months ago

Ahh, interesting, ok. I'll have to look through your data a little more and see if there is anything I can use to distinguish and exclude that.

natekspencer commented 9 months ago

Release 0.1.18 should resolve the errors you are seeing with every call

sambeetm commented 9 months ago

Thank you for the great integration and prompt support. Now I can use these devices to the fullest. One observation though..the status update for any actions taken from HA (like select off/slot1/slot2, RGB etc) takes almost 30 sec to update the status back. I see the actual actions are instant including the status in the app. Just the HA status is delayed. Is it related to this issue ?

sambeetm commented 9 months ago

Updated to 0.1.18. Confirmed that error is gone. But, I still have the 30 sec delay.

natekspencer commented 9 months ago

The 30 second delay is unrelated. This integration uses polling to get the data from Pura APIs which is defaulted to 30 seconds. After making a change, it tries to refresh data pretty quickly, but if the new state isn't available yet, then it waits 30 seconds for the next refresh. You can follow this discussion for updates: https://github.com/natekspencer/hacs-pura/discussions/24