Ambiclimate binding for OpenHAB?

Does anyone have an Ambiclimate and considered making a binding for it for integration into OpenHAB?

They have a fully open API. Before I start investigating building one, wanted to see if anyone else has started on one?

https://api.ambiclimate.com/doc/api

It just uses a REST api but I believe this wouldn’t be able to be used with the HTTP binding as it doesn’t support sending specific headers?? So without building a specific binding for it, could it be scripted with use of curl commands? Has anyone done anything similar with other devices that support the REST api?

I use the Exec Binding to execute bash scripts with curl and jq (for json parsing). It works just fine :slight_smile:

Things

Thing exec:command:ruter_oslobuss [command="sh /home/martin/ruter.sh", interval=300, timeout=5]

Items

String rawosloBusser {channel="exec:command:ruter_oslobuss:output"}

bash script ruter.sh

#!bash
curl -sS http://reisapi.ruter.no/StopVisit/GetDepartures/2300444 | \
 jq 'map(select(.MonitoredVehicleJourney.DestinationName=="Oslo bussterminal"))' | \
jq -c 'map([.MonitoredVehicleJourney.PublishedLineName,.MonitoredVehicleJourney.MonitoredCall.ExpectedArrivalTime])'

Hi Chimera,

Did you ever make the binding for ambiclimate to openhab? I’m very interested in this project, but do not have the expertise to create this.

Hey All,

Anyone want to tackle this project? I would pay to be able to have this binding. I could use the temp/humidity sensors to track my room as well.

Sorry Denny, no I didn’t make any progress. Got busy with other work, still don’t really have time to upskill and write code for this

I guessed that this was the case. I was seeing if I could get this project going by some monetary compensation for anyone’s time. I’m willing to put out $10, let me know if this is a fair price as I’m unsure how much effort will be needed to create this.

I know that Openhab and ambiclimate both have IFTTT integration, but this runs fairly slowly and does not allow me to show the current temp/humidity for the room.

If I were charging for it, I wouldn’t even turn my computer on for $10… however if numerous people are happy to contribute, then it may work out. I’ll throw $10 towards it too.

I want to create a bash script for this, but I’m fairly novice at scripting. How would I get these into variables and post via curl?? Output is returned in json format. I see there is a JSON parser which looks fairly simple to use https://stedolan.github.io/jq/ (eg: jq ‘.access_token’) will take the value of access_token from the JSON output

I’ve tested this, by manually pasting the first 2 into a web browser (the first I have to click ‘Allow’), and obtaining the output with the final command run at CLI to test turning the AC on or off. I just need to convert to a Linux script and use exec binding to run!

Basically, the process is as follows:

Get code from Ambiclimate API

https://api.ambiclimate.com/oauth2/authorize?client_id=MY_CLIENT_ID&redirect_uri=https%3A%2F%2Fhttpbin.org%2Fget&response_type=code

RESPONSE:

{
  "args": {
    "code": "MY_ACCESS_CODE"
  }, 
  "headers": {
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", 
    "Accept-Encoding": "gzip, deflate, br", 
    "Accept-Language": "en-US,en;q=0.9,de;q=0.8,da;q=0.7", 
    "Cache-Control": "max-age=0", 
    "Connection": "close", 
    "Host": "httpbin.org", 
    "Referer": "https://api.ambiclimate.com/oauth2/authorize?client_id=MY_CLIENT_ID&redirect_uri=https%3A%2F%2Fhttpbin.org%2Fget&response_type=code", 
    "Upgrade-Insecure-Requests": "1", 
    "User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
  }, 
  "origin": "public_ip", 
  "url": "https://httpbin.org/get?code=MY_ACCESS_CODE"
}

Get Token (using the Code) from Ambiclimate API

https://api.ambiclimate.com/oauth2/token?client_id=MY_CLIENT_ID&redirect_uri=https%3A%2F%2Fhttpbin.org%2Fget&code=MY_ACCESS_CODE&client_secret=MY_SECRET&grant_type=authorization_code

RESPONSE:

{"access_token": "MY_ACCESS_TOKEN", "token_type": "Bearer", "scope": "email device_read ac_control", "expires_in": 144000, "refresh_token": "MY_REFRESH_TOKEN"}

Tell Ambi to, for example, turn on comfort mode via Ambiclimate API

From Linux CLI, turn on comfort mode:

curl -X GET -G -H “Accept: application/json” -H “Authorization: Bearer MY_ACCESS_TOKEN” “https://api.ambiclimate.com//api/v1/device/mode/comfort

RESPONSE:

[
  {
    "device_online": true,
    "location": "Home",
    "room_name": "Bedroom ",
    "status": "ok",
    "status_code": 200
  }
]

Could anyone offer some linux scripting assistance here?!!!

Doc’s are here. https://api.ambiclimate.com/doc/api

Cheers