Jump to content

TADO° Smart Thermostat WF / invoking URL and IF cases via https


Recommended Posts

Hello everybody,

 

I was just trying to realize a simple workflow to operate the TADO° smart thermostat from the MacBook using Alfred. If have captured the https requests with the two desired options: setting the temperature in AUTO mode, and switching the operation mode from NO_FREEZE, MANUAL to AUTO.

 

Currently, in order to use these https requests, you are forced to login once via the browser to generate the authentication cookie. After that, the https requests are working fine. Is there a more elegant solution for this however?

 

I have then tried to open the URLs using NSAppleScript and shell commands, like: do shell script "curl " & quoted form of theURL but it fails, I guess because of missing AUTH due to absence of cookie. So, I opted for an "Open URL" in Browser object which passes the variable. Backdraw is that this forces the browser to open to fire the request - is there a way to have it closed automatically afterwards?

 

What would be the most elegant way to integrate the keyword "tado temp" followed by a digit where 21,5 should be converted to 21.5 with a decimal, plus "tado mode ON|OFF|AUTO" in one handy compact workflow? It dont fully understand the way how parameters are being passed?

 

Here is my WF: https://www.dropbox.com/s/f7hg9p5h6zzj477/TADO%C2%B0.alfredworkflow?dl=0

 

Thanks in advance for any feedback.

 

Regards,

 

taue2512

Edited by taue2512
Link to comment
  • 2 weeks later...
  • 6 months later...

Can the same be done with cURL? wget isn't installed by default.

 

I really wish that Apple would have just installed wget by default.

 

Anyway, here is the adapted gist to use cURL rather than wget.

#!/bin/sh
#login using sessions/token
# ** Replace YOUR_USERNAME and YOUR_PASSWORD below with your Tado credentials **
curl --header="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" --data="j_username=YOUR_USERNAME&j_password=YOUR_PASSWORD" https://my.tado.com/j_spring_security_check --cookie-jar /tmp/tadocookie.txt -o /tmp/tadologin.out > /dev/null 2>&1
#Get the thermostat settings xml (inc temperatures)
curl --header="Content-Type: application/x-www-form-urlencoded; charset=UTF-8" --header="X-Requested-With: XMLHttpRequest" --cookie /tmp/tadocookie.txt https://my.tado.com/mobile/1.4/getThermostatSettings -o /tmp/tadotemps.xml > /dev/null 2>&1
#Get out the temps from the xml
THERMOSTAT_TEMP=$(cat /tmp/tadotemps.xml | jq -r '.temperatures.externalTempSensor')
CONTROL_BOX_TEMP=$(cat /tmp/tadotemps.xml | jq -r '.temperatures.box')
#Print out temps to 1 decimal place
printf "Kitchen: %0.1f°C\n" $CONTROL_BOX_TEMP
printf "Living Room: %0.1f°C\n" $THERMOSTAT_TEMP

It **should** work, but it's not tested. I just redid the options to change them from wget to curl.

 

But it also looks like you need jq installed. jq is a great utility to let you work with structured data (xml, json) from a shell. If you want to make this workflow available for distribution, then you should probably use some other sort of scripting language that supports structured data with minimal headache but use the same approach via storing cookies and setting headers.

Edited by Shawn Rice
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...