dwradcliffe / home-assistant-waterguru

Home Assistant custom integration for WaterGuru
MIT License
16 stars 0 forks source link

Missing PH Sensor #7

Open madasus opened 2 months ago

madasus commented 2 months ago

For the past few days my installation has been telling me that the PH entity is no longer provided. Anyone else seeing this? did they rename something on the API?

image

dwradcliffe commented 2 months ago

I just checked and mine worked ok this morning. Try restarting HA?

madasus commented 2 months ago

Yeah I restarted HA and the integration.

I am in a PH alert state right now - pH low.

Maybe it breaks where there is a PH Alert?

dwradcliffe commented 2 months ago

Did you happen to replace your cassette recently? If HA restarts right after your cassette is replaced this might happen.

If this happens again you can press the debug button on this integration and send me the debug output it gives you.

madasus commented 2 months ago

No - it was replaced a week or so ago - i've had 3 or 4 readings from this cassette already so it should be fine.

config_entry-waterguru-e3cc3dc5130af6ac741899bb46ef5bbf.json

Is this the correct file?

WorldOfMaze commented 2 months ago

@madasus Mine is working fine. I am using the original -- pH + Chlorine levels only -- WaterGuru.

madasus commented 2 months ago

Confirmed - I cleared the PH error today (by fixing the water in the pool!) and now the PH numbers are showing back up in HA.

Looks like the integration maybe isn't handling PH related errors correctly?

dwradcliffe commented 2 months ago

That was the correct debug file, thank you. I looked at your data and the code and my data and I can't figure out why it wouldn't work. Were there any errors in your log?

madasus commented 2 months ago

It looks like there was

024-07-13 07:12:50.184 ERROR (MainThread) [homeassistant.components.sensor] Error adding entity sensor.waterguru_newtown_ph for domain sensor with platform waterguru Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 598, in _async_add_entities await coro File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 912, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1362, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1007, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1133, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.__async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1072, in __async_calculate_state if extra_state_attributes := self.extra_state_attributes: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/waterguru/sensor.py", line 226, in extra_state_attributes a[WaterGuruEntityAttributes.ADVICE] = m.get("alerts")[0].get("advice").get("action").get("summary") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get' 2024-07-13 07:12:50.199 ERROR (MainThread) [homeassistant.components.sensor] Error adding entity sensor.waterguru_newtown_ph_alert for domain sensor with platform waterguru Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 598, in _async_add_entities await coro File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 912, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1362, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1007, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1133, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.__async_calculate_state() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1072, in __async_calculate_state if extra_state_attributes := self.extra_state_attributes: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/waterguru/sensor.py", line 226, in extra_state_attributes a[WaterGuruEntityAttributes.ADVICE] = m.get("alerts")[0].get("advice").get("action").get("summary") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

dwradcliffe commented 2 months ago

Ah! I see the problem now. I'll work on a fix. It seems that because you didn't set the type of acid you use, it doesn't give you any advice and the API result is different. The code should handle this.