Flume Water Meter

Thanks got it working.

Thanks for making this. Just got a flume, yesterday and everything seems to be working well. So far I really like it, was wanting to get my water usage into HA somehow and Flume seems like the easiest way.

Are the “Last 60min” and “Last 24hr” sensors essentially rolling sum measurements?

I think I prefer just a sum of the last minute if the query is running every minute. Then HA can make all the other sensors using its built in stats sensors and such.

I modified your code to additionally give the 1 minute measurement, i like it because it matches the app better, that and the cumulative sum measurements make more sensor to me vs the last 60min/24hr sensors.

Just my 2 cents fwiw

1 Like

Yes, those queries are sums. The Last 24hr one in particular I tweaked to make sure that it matched the figure shown in the app.

I like your idea of supporting the statistics sensor, so I added a current_min sensor to my version as well. You could also use this to drive a template binary sensor, which I think would approximate what the app is doing for Water Status (Running / Not Running).

Does anyone have any ideas. It was working, but after a restart I get this.

Error while setting up platform flume
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/flume/sensor.py", line 44, in setup_platform
    sensor_list = list(flume.get_usage().keys())
  File "/config/custom_components/flume/flume_homeassistant.py", line 121, in get_usage
    return {k: v[0]['value'] for k, v in values.items()}
  File "/config/custom_components/flume/flume_homeassistant.py", line 121, in <dictcomp>
    return {k: v[0]['value'] for k, v in values.items()}
IndexError: list index out of range

Still can’t figure this out. Removed flume tokens file but no change.

Is there a way to see if the water is running?

Could use a template sensor with
value_template: {{ states('sensor.flume_current_min')|float > 0 }}

I pushed a couple updates to this project:

  • Added rate limiting to the API calls
  • Added support for litres instead of gallons (:canada:):
    • unit_of_measurement: L

If you’re updating, make sure to grab the manifest.json file, as it’s changed as well.

@ender7 Are you still having trouble?

Actually most of the world :slight_smile:

1 Like

@michaeldavie, yes. I reboot HA regularly as I am working on some configs. The flume plugin will throw this error and not get results after 80-90% of the HA restarts. Eventually, if I restart enough, it will eventually work, but then error again on next reboot. I’m just using it stock. No changes. Deleting flume tokens doesn’t have any effect. It seems to be getting data in that list it doesn’t expect.

@ender7 I think I’ve fixed this. It had to do with the API limit, which I think I’ve accounted for correctly in the latest version. Please give the latest files a try and let me know if it’s working correctly for you or not.

For those interested in a running water binary sensor, I think this should do the trick:

binary_sensor:
  - platform: template
    sensors:
      water_running:
        device_class: moisture
        value_template: "{{ states('sensor.current_min') | float > 0 }}"

Thanks. Will do. In the process of porting my vm’s and docker containers to a new server, but will give this a try and report back as soon as they are back up and running.

I’m still having the IndexError: list index out of range on the newest version.

I also have problems with the latest release.
Here is portion of my log file.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 249, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/flume/sensor.py", line 91, in update
    self.flume.update_usage()
  File "/config/custom_components/flume/flume_homeassistant.py", line 16, in res
    return fun(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/ratelimit/decorators.py", line 80, in wrapper
    return func(*args, **kargs)
  File "/config/custom_components/flume/flume_homeassistant.py", line 139, in update_usage
    values = response.json()['data'][0]
IndexError: list index out of range
2019-08-18 10:26:02 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.last_24_hrs fails

This is great work. I am getting the Flume and looking forward to using it. I was wondering if anyone in this thread also has Smartthings? I noticed there was a way to connect Smartthings to Home Assistant, so I figured I would ask in here. So far, I am not aware of any integration between Flume and Smartthings, but it would be great to be able to see the data and create actions based on water flow (e.g., shutting off an automatic water valve after certain parameters are met).

Why would you need smart things for that if the flume is available as a home assistant integration?

I don’t have Home Assistant, at least not yet. There might also be things that can be learned in the integration here that might help users on other platforms, such as Smartthings and Hubitat. I do know some people have multiple platforms.

That is fine, but this forum is about home assistant.

I’m having the index error as well after a restart. Any way to tell if it is hitting the API limits? I suspect that might be the cause.