Got a Delta VoiceIQ a while back which integrates to Alexa, and thanks to a script that @vitaliy_kh found and help from ChatGPT and @tomw, a driver has been developed that will work with Hubitat.
* delta_device_id - click on usage - it will be in the URL https://device.legacy.deltafaucet.com/#/device/usage/<your_device_id_here>
delta_device_id: <your device id>
* delta_token
Go to inspector (Ctrl + Shift + I) -> Console;
Type window.localStorage.auth_token a long string will come up. delta_token should be compiled as follows:
delta_token: Bearer <the string from above without quoted>
From the Chrome View menu at the top of the screen, select Developer > JavaScript Console
At the top of the console window, click on the Network tab.
On the Delta faucet page, click on the blue button labelled Water Usage - This Week
Expand the left side of the inspector window.
On the Name column, click on the result that starts with UsageReport?deviceId=
On the Headers column, under Request Headers you will find the required deviceId (also shown in the URL address bar after usage/) and the full Authorization token needed.
NOTE: Copy the entire authorization token after the word Bearer. It ends with and must include =
I am learning how to deal with HA configuration.
After multiple trial/error attempts finally I got it working in HA.
Here is working version of the above HA configuration script (only on/off commands are tested):
input_text:
delta_device_id:
name: delta_device_id
initial: !secret delta_device_id
rest_command:
delta_water_on:
method: POST
url: >
https://device.legacy.deltafaucet.com/api/device/toggleWater?deviceId={{states.input_text.delta_device_id.state}}&toggle=on
headers:
Authorization: !secret delta_token
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Referer: https://device.legacy.deltafaucet.com/
delta_water_off:
method: POST
url: >
https://device.legacy.deltafaucet.com/api/device/toggleWater?deviceId={{states.input_text.delta_device_id.state}}&toggle=off
headers:
Authorization: !secret delta_token
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Referer: https://device.legacy.deltafaucet.com/
Bye, bye Alexa! (One cloud less.)
I am sure, the same HTTPS POST could be implemented in HE.
Most likely not directly from the RM but simple custom Driver or App could be created for sure.
How did you get the token? I tried the method on GitHub but I don't find "window.localStorage.auth_token". I'm only able to find my device ID in the URL.
Also tried the instructions from the HomeBridge plugin, but they don't make sense to me and don't yield a result I recognize as the secret I need for my faucet.
Any help would be much appreciated. I've wanted to have something like this working for several years now.
Please check the very first post in this thread.
You have to click on "show original" in order to see the entire document.
The instruction is on top under README section.
The HA configuration in the above document is not working but I got it right.
I just ask ChatGPT to translate the script to a driver for Hubitat, and tried to update it to allow it to work with the token. The driver saves, but I get an error when pressing one of the buttons:
Edit - Updated the following on 2023-06-04 at 16:24 AST
Progress... but we may need someone with actual Groovy experience to chime in... @thebearmay maybe...?
Also, I would want to put the proper author author and name space... not sure what belongs there since it is based on a script from "velaar" that ChatGPT converted and that I unsuccessfully updated to try to make work, and that hopefully, someone will be able to help fix...?
Wow! Nice try.
Original "velaal" scripts did not work "as is". I was able to get them working.
At this time everything is working in HA and I am finishing integration with HE via HADB.
So, Alexa is gone. Everything is working with HE-HA integration (plus and unfortunately
Delta Cloud). But sure, it will be very nice even to bypass HA.
Do I understand you had to change the script for it to work? If so, could you share the version that worked in case that may make a difference?
Also, when getting my token, it seems to be truncated (ends with ...) - do you also see this?
Finally, I don't yet understand the proper format for the token in the script/Grovee... Is this what should be passed (just typed random letters for the example...):
Yes. I had to split single "toggle" command into two separate On/Off commands because
the original was missing "payload".
Here is just tested positive configuration from my HA YAML file:
rest_command:
delta_water_on:
method: POST
url: >
https://device.legacy.deltafaucet.com/api/device/toggleWater?deviceId={{states.input_text.delta_device_id.state}}&toggle=on
headers:
Authorization: !secret delta_token
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Referer: https://device.legacy.deltafaucet.com/
delta_water_off:
method: POST
url: >
https://device.legacy.deltafaucet.com/api/device/toggleWater?deviceId={{states.input_text.delta_device_id.state}}&toggle=off
headers:
Authorization: !secret delta_token
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Referer: https://device.legacy.deltafaucet.com/
For the beginning I removed "delta_dispense_mills" command but it should work as well as
all other commands available from Delta Faucet Control web page.
(Frankly, I am using only On/Off commands in my automations.)
Yes. But actual TOKEN is about 500 characters long. You have to hit "enter" in the console
window and it will show up entirely. You can use a "network" window. It has a lot more info.
That is how I figured out the original script was not right.
Thanks! That's what I was missing. Still getting the Error 500 when I try to "Save Preferences" - not sure why yet... Will likely not be able to go much further on this before I need to go walk the dog...
When I don't make the token mandatory and leave the field blank, it works, so likely an issue with the variable type...?
I see my mistake. Was trying to 'find' in the console instead of typing that in the console. I have my token, but I seem to be too dense to work from the limited instructions for both HA and the HomeBridge plugin.
I'll just watch and wait until something emerges that I can understand how to configure and use.
For the HA you can use my modified config script right now
(currently and for the beginning only on/off commands are implemented).
I am not using HomeBridge and have no idea what it is.
This is exactly my setup.
Everything is on C8 (ZWave + Zigbee + All_Automations). In addition hub-meshed C7 handles
all LAN and Cloud Devices. And HA via HADB brings in Bluetooth Devices plus whatever is
not available on HE.
No worries! I’ll take a look at the Plugs and switches driver to compare. Any chance you might know what would cause a 500 error when I try to save the very, very long Token?
I tried removing the "input" string and just hard coding the Token and didn't get the 500 error, so I think that maybe there is too much data for a "text" type variable...?
Still stuck at the other error though, and don't have enough knowledge/background to know where to start debugging it...
Cool. I could use some help with how to use this in the HA automation if you can spare the time.
What would likely make it clear enough for me to follow would be to see exactly how my configuration.yaml should look with this, and exactly how my On and Off automation yaml should look.