@kahn-Hubitat - I updated to the most recent version, and initial results are good. (Sorry for the delay... busy week and I wasn't wasn't watching this post for some reason... missed the recent updates). Once I installed the driver, app, and then transitioned token, I just had to do a manual refresh to the endpoint to update the app. I do want to move to the new Access/Refresh Token option in the app so all the other external junk isn't needed, but I'll continue to use the endpoint for a bit to test. Also, I just want to make sure that proper credit is given and call out that "brad's code" referenced above was 99% done by @thebearmay.
3 additional items to note:
1. Window attributes types need to be updated. The values are open
and closed
, so these should be strings instead of numbers. You can't use these correctly in rule machine if they are set as numbers (and this actually broke my rules that use it):
attribute "front_drivers_window" , "number"
attribute "front_pass_window" , "number"
attribute "rear_drivers_window" , "number"
attribute "rear_pass_window" , "number"
2. Commands are still failing when the car is asleep. There is only a 2 sec pause, so I'm getting Request failed for path: /api/1/vehicles/1234567890/command/window_control. [response:null, error:vehicle unavailable: {:error=>"vehicle unavailable:"}, error_description:]
To fix this and check for online state, @thebearmay helped me replace the commands to include a delay (example below), but as we discussed in our direct message, I agree a better option would be to wake and then retry every 5-10 seconds until success since the 30 seconds used here could be too little or too much, depending.
def ventWindows(child) {
wake(child)
pause(2000)
return executeApiCommand(child, "window_control", body: [command: "vent"])
}
with
def ventWindows(child) {
def data = [:]
def id = child.device.deviceNetworkId
authorizedHttpRequest("/api/1/vehicles/${id}", "GET", { resp ->
data = transformVehicleResponse(resp)
})
if (data.state == "online") {
pause(2000)}
else {
wake(child)
pause(30000)}
return executeApiCommand(child, "window_control", body: [command: "vent"])
}
3. A nit-pic, but unlockandOpenChargePort
results in a joined command because the A is not uppercase. I had updated my versions to simply openChargePort
Device
command "openChargePort"
def openChargePort() {
log.debug "Executing 'unock and open charge port'"
def result = parent.openChargePort(this)
}
App
def openChargePort(child) {
wake(child)
pause(2000)
return executeApiCommand(child, "charge_port_door_open")
}