gkreitz / homeassistant-grohe_sense

Grohe Sense integration for Home Assistant
MIT License
42 stars 25 forks source link

Fixed new api #34

Open weissm opened 11 months ago

weissm commented 11 months ago

Appearently Grohe has changed its Api. Took the changes discussed here as basis: https://github.com/FlorianSW/grohe-ondus-api-java/issues/14

svalavuo commented 11 months ago

I made all the changes to files, but I still can't get any values to HA. HA Log shows:

Logger: homeassistant.helpers.entity
Source: custom_components/grohe_sense/sensor.py:128
Integration: Grohe Sense ([documentation](https://github.com/gkreitz/homeassistant-grohe_sense))
First occurred: October 4, 2023 at 19:49:30 (1 occurrences)
Last logged: October 4, 2023 at 19:49:30

Update for sensor.minun_guard_flowrate fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 683, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 936, in async_device_update
    await self.async_update()
  File "/config/custom_components/grohe_sense/sensor.py", line 249, in async_update
    await self._reader.async_update()
  File "/config/custom_components/grohe_sense/sensor.py", line 128, in async_update
    w['starttime'] = parse_time(w['starttime'])

What might be the problem?

weissm commented 11 months ago

I made all the changes to files, but I still can't get any values to HA. HA Log shows:

Logger: homeassistant.helpers.entity
Source: custom_components/grohe_sense/sensor.py:128
Integration: Grohe Sense ([documentation](https://github.com/gkreitz/homeassistant-grohe_sense))
First occurred: October 4, 2023 at 19:49:30 (1 occurrences)
Last logged: October 4, 2023 at 19:49:30

Update for sensor.minun_guard_flowrate fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 683, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 936, in async_device_update
    await self.async_update()
  File "/config/custom_components/grohe_sense/sensor.py", line 249, in async_update
    await self._reader.async_update()
  File "/config/custom_components/grohe_sense/sensor.py", line 128, in async_update
    w['starttime'] = parse_time(w['starttime'])

What might be the problem?

From my understanding, 'starttime' is not provided anymore via the new API. Hence, the associated checking code seems to be void. You may either check for the existance of 'starttime' or remove this if section. Hope, this helps.

svalavuo commented 11 months ago
  File "/config/custom_components/grohe_sense/sensor.py", line 128, in async_update
    w['starttime'] = parse_time(w['starttime'])

What might be the problem?

From my understanding, 'starttime' is not provided anymore via the new API. Hence, the associated checking code seems to be void. You may either check for the existance of 'starttime' or remove this if section. Hope, this helps.

So I should remove everything from line 124 to line 137. Quite big chunk of code...

svalavuo commented 11 months ago

Now it seems to get some data from Grohe. I set HA loglevel to debug, booted my host, and now I can see following in container log: [custom_components.grohe_sense.sensor] Data read: {'group_by': 'day', 'measurement': [{'date': '2023-10-08', 'flowrate': 0.2, 'pressure': 5.22, 'temperature_guard': 14.62}, ..., 'withdrawals': [{'date': '2023-10-08', 'waterconsumption': 91.3, 'hotwater_share': 9.4, 'water_cost': 0.4, 'energy_cost': 0.04}, ...]} Should HA (grohe integration) understand that directly? If so, how should those sensors show up in HA? Sorry to flood this, but I'd like to have that integration working. Thanks for the fix to API! This should be merged to main asap.

weissm commented 11 months ago

This should indeed show up as sensor entity. The name should start with the one you provided in the Grohe App. All data you show are refering to GROHE_SENSE_GUARD_TYPE.

areeeee commented 11 months ago

Nice job! I had it fully working a few days :) Suddenly all sensors from the grohe sense guard unit is gone. pressure, flowrate, temperature, 1 day and 7 day. The main valve button is still there and working. Has anything changed or is this a problem on my end?

I am getting a lot of these messages in the logs: WARNING (MainThread) [homeassistant.components.sensor] Updating grohe_sense sensor took longer than the scheduled update interval 0:00:30

The flood sensors updates humidity and temperatures once every 24 hours.

Another question. I get the notifications in HA for flooding, but no notifications when the flooding is fixed. Is this correct? I was hoping to make these into binary sensors, but with no reset that's probably no good.

weissm commented 11 months ago

Please note that the update changed proposed above by FlorianSW is now utilizing a daily update. Hence, at least the 24h update frequency could be understood. Everything else sounds akward, while the warning itself is standard for the sensor having problems starting up. Hope you can fix it.

svalavuo commented 11 months ago

This should indeed show up as sensor entity. The name should start with the one you provided in the Grohe App. All data you show are refering to GROHE_SENSE_GUARD_TYPE.

For some reason my integration doesn't bring any sensors or entities. :-( Integration doesn't give errors on start, so it should be ok. I'm quite confused.