You've gotten farther along than I have. I did install Big5 (I already owned it but never installed it) and started reading the API docs.
Announcement
Collapse
No announcement yet.
Flume Intelligent Water Sensor
Collapse
X
-
No offense to Big5, maybe I don't know how to use it well, but it seems cumbersome for something like this based on my current experience.
Some in the HomeAssistant/Flume forum, someone using HomeAssistant wrote this for Flume...
https://github.com/michaeldavie/flume-sensor
It's in Python, he's keeping it updated it seems. Wish HS supported other languages. Maybe this could be converted to VB.script at a min.
G
P.S. I never even heard about HomeAssistant before today
Comment
-
I worked through the API documentation yesterday. Thankfully, most of the data needed is static. Flume has a reasonable documentation site that walks you through the process of authentication and getting data. The only 2 dynamic pieces you need are the authentication token (what they call a bearer token) and a refresh token that is used to refresh the bearer token as it's good for 7 days.
You also need user_id, device_id, client_id, client_secret, username, and password. The last 2 are from your sign-up account, and the 2 prior to that are provided when you generate the API key. You can get the user_id and device_id with the Flume API documentation, and they are static, so once you have them you don't need the API any further except to pull data and refresh the authentication key every 7 days.
The output of the Flume API is all JSON, so it appears to be ideal for Big5. I've worked out the Big5 parsing in the Big5 "sandbox" and just need to setup the events. I hope to finish all that by this weekend and will post details.
This exercise has allowed me to expand my horizons on Big5, it will be useful for other data as well.
Comment
-
OK, I've got the flume API data into HomeSeer. Here are the steps I took.
First, you'll need to get an API key at https://portal.flumetech.com/settings bottom of the page
Copy the Client ID and Client Secret.
The easiest way to collect the rest of the data needed is at the flume documentation site, https://flumetech.readme.io/reference
Scroll down to "Get Token" and fill in the form requirements:
Client_id - copied from flume portal
Client_secret - copied from flume portal
Username - your portal sign up email
Password - your portal password
Click the "Try it" button next to https://api.flumewater.com/oauth/token
In the grey box to the right of the button you should see the returned output. Make sure it says "success": true
Copy the access token in quotes, a long string like this:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODk wIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJ SMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
Head over to https://jwt.io/#debugger-io
In the box that says "paste a token here" paste in the access token.
Under payload: data in the right, look for user_id: xxxxx a number. In my case it was 5 digits
Copy the user_id
Close this page, we don't need anything else.
Go back to the Flume documentation page and scroll down to "Fetch Users Devices"
Fill in the form:
User_id - you just got that
Click the "Try it" button next to https://api.flumewater.com/users/user_id/devices
This time a popup will appear that says the bearer token is required. Paste the copied bearer token from above (the long string) and continue.
In the output to the right, look for the device id of type 2
"id": "6248148189204194987",
"bridge_id": "6248148189204194444",
"type": 2,
Copy the "id" on the first line, not the bridge id. In this case the line ending in 987
Now you have all the static information you will need to query water usage. On to HomeSeer setup.
Here's where you have to make some decisions. I decided I only want hourly usage data. I created the following virtual devices:
WaterMonthlyUsage - Holds the monthly total gallons, calculated from daily
WaterDailyUsage - Holds the daily total gallons, calculated from hourly
FlumeStartDate - Holds the query start date/time string, calculated by event
FlumeEndDate - Holds the query end date/time string, calculated by event
The remaining devices will be created by Big5 when executing events.
Big5 Setup:
I created 2 HTTP profiles
Flume-Auth-Init
FlumeQueryData
Screenshots of Big5 don't show all the details, so here is how I filled out the form:
URL: https://api.flumewater.com/oauth/token
Request/response body: {"grant_type":"password","client_id":"YOURCLIENTID","clie nt_ secret":"YOURCLIENTSECRET","username":"YOURFLUMEPORTALUSERNA ME","password":"YOURFLUMEPASSWORD"}
Extra headers: content-type: application/json
Device Name Expression: FlumeAccessToken && FlumeRefreshToken
Device Value Expression: JSON(input,"data[0].access_token") && JSON(input,"data[0].refresh_token")
My device name expression wasn't quite right, showing my lack of experience with Big5, but it created the 2 devices and I just renamed them manually
The device value expression was critical, and that is right.
I created a manual event to execute this profile in Big5.
And then ran the event, it created 2 devices, 1 with the bearer/authorization token, and 1 with the refresh token. I just renamed them FlumeAuthToken and FlumeRefreshToken. You will need the device reference numbers later, so make note of those.
Next I created events to generate the start and end query datetime strings. I'm a lazy (read poor) programmer, so I chose to create the 2 strings by generating 1 before the top of the hour and 1 after so the Now() function lined up with my needs. I'm sure this could be improved on. It's critical that these device strings are correct when the query event is executed. That's why I set the start date event at 55 minutes after the hour, the end date event at 5 minutes after the hour, and the query at 10 minutes after the hour. These could be tightened up to query the data closer to the hour, but I don't know how long it takes the device to update.
Set Water Consumption End Date - Executed 5 minutes after every hour, creates the end date string used by the Big5 FlumeQueryData profile to set which hour of data is requested. The string is held in the device FlumeEndDate, device reference number 1573.
Set Water Consumption Start Date - Executed 55 minutes after every hour, creates the start date string used by the Big5 FlumeQueryData profile to set which hour of data is requested. The string is held in the device FlumeStartDate, device reference number 1572.
Water Consumption Data
The flume query data returned looks like this. You can read details in the documentation portal from before under "Query a User's Device". Since I'm querying for hourly data and only 1 hour, I only get 1 data point back. This is in JSON format. If you need to make changes, I would recommend Notepad++ and the JSTool plugin, it will help you format and understand the data.
{
"success": true,
"code": 602,
"message": "Request OK",
"http_code": 200,
"http_message": "OK",
"detailed": null,
"data": [
{
"1": [
{
"datetime": "2020-07-16 15:00:00",
"value": 4.64374118
}
]
}
],
"count": 0,
"pagination": null
}
Next I created the second Big5 HTTP profile to run each hour to get the water consumption data.
Fill in the form like this. Be sure to replace the 2 variables in the URL and device reference numbers in the body:
URL: https://api.flumetech.com/users/YOUR...DEVICEID/query
Request/response body: {"queries":[{"request_id":"1","bucket":"HR","since_datetime":"${str15 72} ","until_datetime":"${str1573}"}]}
Extra headers:
content-type: application/json
authorization: Bearer ${str1569}
Device value expression: JSON(input,"data[0].1.[0].value")
Note: str1572 is the reference number of FlumeStartDate device, str1573 is the reference number of FlumeEndDate device, str1569 is the reference number of FlumeAuthToken
Cut and paste may be the best way to deal with most of this. Any mistakes will cause the query to fail.
Query Events and Device Updates.
Here are the events I created to get the data hourly and increment or reset the various devices as needed.
Flume Query Hourly Water Usage - executed hourly to update hourly water usage. The event also updates the WaterDailyUsage by adding WaterHourlyUsage to WaterDailyUsage
Reset Water Monthly Usage - Reset the monthly water usage counter to 0 at the beginning of each month.
Update Monthly Water Usage - Executes daily to add WaterDailyUsage to the WaterMonthlyUsage device and reset the daily usage to 0.
I added all the devices for hourly, daily, and monthly consumption to Device History, so I could graph the usage.
Todo: The auth/bearer key is good for 7 days. I/You will need to schedule the manual Auth init event to run weekly, or build a new Big5 profile to use the refresh key. Honestly I don't know why you would use the refresh key process since generating the bearer key works over and over.
Hope that helps anyone who wants to integrate this device in HomeSeer. It sounds more difficult on paper than it is. I'm happy to answer any questions I can.
- Likes 1
Comment
-
Just a quick update if anyone plans to follow my example - I found a logic error in the process. The event "Update Monthly Water Usage" should be set to execute after the last query of the day, which is 00:10 in my example. I had it set to midnight, which moved the previous day's last hour usage to the next day. The fix is to execute the event after 10 minutes after the hour, so I set it to execute 15 minutes after midnight instead of midnight.
Came across this comparing the app totals to mine.
Comment
-
Originally posted by devoir View PostWhat are the physics of how this device works? I really like this idea but how is it recording the flow? What sensor does it use for counting?
PS thanks for the work on the plug-in
Devoir
I have a secondary meter on my in-house water (installed in the garage next to my water softener) with a sonoff basic providing pulse feedback to HS. If I could, I would go this route for the primary meter rather than use Flume, but location prevents it. Between the two devices I can monitor house, irrigation and total usage.-Wade
Comment
-
Post what you got from the steps in post # 20 above, after you have filled out the data in https://flumetech.readme.io/reference and get a JSON response. Doesn't seem like you are performing that step correctly. You shouldn't get any errors in Big5.
Comment
Comment