[677] Tado thermostat
Moderators: leecollings, remb0
-
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
Re: [677] Tado thermostat
I run this script on startup of my Synology using the following bash script:
#!/bin/bash
php70 -f tado.php > /dev/null &
the PHP script has a 'while true' loop, so it runs indefinitely (unless there is a problem - haven't added any code to deal with this yet) and a variable declared in the start of the script
$sleep_time = "60";
means that it 'sleeps' for 60 seconds each time (i.e. runs once a minute). There is little/no point running more frequently, as Tado does not update more frequently, unless there is a >2% change
#!/bin/bash
php70 -f tado.php > /dev/null &
the PHP script has a 'while true' loop, so it runs indefinitely (unless there is a problem - haven't added any code to deal with this yet) and a variable declared in the start of the script
$sleep_time = "60";
means that it 'sleeps' for 60 seconds each time (i.e. runs once a minute). There is little/no point running more frequently, as Tado does not update more frequently, unless there is a >2% change
-
- Posts: 3
- Joined: Saturday 05 November 2016 12:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [677] Tado thermostat
Does anyone has a Lua script to control my tado thermostat from domoticz?
I tried to use the script of https://github.com/WebSpider/tado_domoticz but when paste that script in domoticz, nothing happens.
I tried to use the script of https://github.com/WebSpider/tado_domoticz but when paste that script in domoticz, nothing happens.
-
- Posts: 56
- Joined: Wednesday 24 December 2014 16:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [677] Tado thermostat
If you would have taken the effort to actually read this thread, you would have known that Tado has changed their API causing the LUA you use no longer to work.
-
- Posts: 10
- Joined: Wednesday 20 May 2015 23:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3.7392
- Location: Netherlands
- Contact:
Re: [677] Tado thermostat
Thank you very much for sharing the script. Works like a charm for me.rjblake wrote:I run this script on startup of my Synology using the following bash script:
#!/bin/bash
php70 -f tado.php > /dev/null &
the PHP script has a 'while true' loop, so it runs indefinitely (unless there is a problem - haven't added any code to deal with this yet) and a variable declared in the start of the script
$sleep_time = "60";
means that it 'sleeps' for 60 seconds each time (i.e. runs once a minute). There is little/no point running more frequently, as Tado does not update more frequently, unless there is a >2% change
It would be nice to have this added to Domoticz as a built-in hardware.
-
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
Re: [677] Tado thermostat
I was hoping to have a look at doing this, but have just not had the time lately due to work and other commitments. Might only be able to start on it in a few months, if luckyeXisTa wrote:Thank you very much for sharing the script. Works like a charm for me.
It would be nice to have this added to Domoticz as a built-in hardware.
-
- Posts: 57
- Joined: Sunday 03 January 2016 17:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [677] Tado thermostat
tado.php doesnt work anymore, I think they changed again someting in tado...
-
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
Re: [677] Tado thermostat
Tado changed the API and unfortunately since it is not published, was not known. They've introduced 'client_secret' requirement, so the code has been modified (I think the client_secret is the same for all users and linked to the app/client). The code on GitHub has been updated and is working again.
-
- Posts: 3
- Joined: Wednesday 19 July 2017 12:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [677] Tado thermostat
Hi, thanks for building the new script! I'm trying to get it to work on my RPi, and I'm encountering these errors. Any pointers?rjblake wrote:Tado changed the API and unfortunately since it is not published, was not known. They've introduced 'client_secret' requirement, so the code has been modified (I think the client_secret is the same for all users and linked to the app/client). The code on GitHub has been updated and is working again.
Code: Select all
Token Age: 21 | Used cached token | PHP Notice: Undefined index: homes in /home/pi/domoticz/scripts/tado.php on line 129
PHP Notice: Undefined index: type in /home/pi/domoticz/scripts/tado.php on line 455
PHP Notice: Undefined offset: 0 in /home/pi/domoticz/scripts/tado.php on line 297
PHP Notice: Undefined index: setting in /home/pi/domoticz/scripts/tado.php on line 317
PHP Notice: Undefined index: sensorDataPoints in /home/pi/domoticz/scripts/tado.php on line 318
PHP Notice: Undefined index: sensorDataPoints in /home/pi/domoticz/scripts/tado.php on line 319
PHP Notice: Undefined index: sensorDataPoints in /home/pi/domoticz/scripts/tado.php on line 320
HomeID: - ZoneID: - Temp&Humidity: ;;2 - Setpoint:
-
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
Re: [677] Tado thermostat
Yup - Tado went and changed the API again!! Will try check later tonight to see if I can find a fix
-
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
Re: [677] Tado thermostat
I've updated the code. Should work now. They changed the 'client_id' and 'client_secret' in what looks like a step closer to releasing a public API. Hope they do as these break/fix solutions aren't much help
-
- Posts: 3
- Joined: Wednesday 19 July 2017 12:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [677] Tado thermostat
Wow you are quick, thanks! It makes clear that the Tado change and my "mess" was a coincidence: I still get these results from running the php file:
Since I installed this on a "fresh" Pi3, I had to install PHP/curl etc. Maybe I messed up there. Anyhow, I'm not able to troubleshoot any further. Tho you mentioned that this is just a "quick fix" script, I appreciate any help!
Code: Select all
Token Age: 2 | Used cached token | PHP Notice: Undefined index: homes in /home/pi/domoticz/scripts/tado.php on line 134
PHP Notice: Undefined index: type in /home/pi/domoticz/scripts/tado.php on line 460
PHP Notice: Undefined offset: 0 in /home/pi/domoticz/scripts/tado.php on line 302
PHP Notice: Undefined index: setting in /home/pi/domoticz/scripts/tado.php on line 322
PHP Notice: Undefined index: sensorDataPoints in /home/pi/domoticz/scripts/tado.php on line 323
PHP Notice: Undefined index: sensorDataPoints in /home/pi/domoticz/scripts/tado.php on line 324
PHP Notice: Undefined index: sensorDataPoints in /home/pi/domoticz/scripts/tado.php on line 325
HomeID: - ZoneID: - Temp&Humidity: ;;2 - Setpoint:
-
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
Re: [677] Tado thermostat
Can you attached the PHP file you are using? The line numbers where the errors are appearing do not match up to my script, so not sure what else you've changed. Also, I am running this using PHP 7.0; but can't recall if I used any specific v7.0 functions offhand (have run it with php v5.6.11 and it runs). It looks like the token file may have not have been created/written. Check if there is a file in your /tmp/ directory. The file/location is specified in the script ($token_file = "/tmp/tadotoken";). The 'user' that is running the script will need read/write permissions here.
Additionally, you'll need the JSON modules/extension installed if they are not as this will definitely cause an issue (check to see modules installed with "php -m" or "php70 -m").
Additionally, you'll need the JSON modules/extension installed if they are not as this will definitely cause an issue (check to see modules installed with "php -m" or "php70 -m").
-
- Posts: 3
- Joined: Wednesday 19 July 2017 12:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [677] Tado thermostat
First problem is that I screwed up copying the code from GitHub, that's corrected now. I'll check for the JSON library, thanks!
At least I'm getting the actual temp now, great
At least I'm getting the actual temp now, great
-
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
Re: [677] Tado thermostat
That would certainly cause a problem...jelmerk wrote:First problem is that I screwed up copying the code from GitHub, that's corrected now. I'll check for the JSON library, thanks!
At least I'm getting the actual temp now, great
If you are getting the actual temperature, that's a good start. If so, all good with the JSON bits as these are required to extract the temp/humidity. As long as you update the Domoticz bits in the code, it should be updating the devices in Domoticz too
-
- Posts: 19
- Joined: Friday 04 August 2017 19:21
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: [677] Tado thermostat
Hi Guys, Hopefully you can help me. I wish to use the tado api to find out whether or not tado is current calling for heat and use this to toggle a virtual switch. The end goal is to make 2 set's of electric underfloor heating systems 'smart' by leveraging the power of tado geofencing and heating demand management.
So far I have identified the variable I require and added to the latest version of the script to parse this out as an 'On' or 'Off' variable. However I'm having trouble updating a virtual switch. I added a function to update a switch device but the domoticz switch itself doesn't update.
Below are all my modifications in case it helps someone, maybe @rjblake can incorporate them into his script once we have them working if others will find this useful?
UPDATE 18-9-17
Not sure what I did but it works now. So the script queries tado api to find out whether or not there is currently a demand for heat and uses this to toggle a DOMO virtual switch. I plan to use that virtual switch to trigger sonoff relays. I've also added a check within the script so that it only updates the switch if the demand has changed, rather than continually updating it, therefore I can use logic like - if switch is off and last update was > 10 mins etc etc etc
So far I have identified the variable I require and added to the latest version of the script to parse this out as an 'On' or 'Off' variable. However I'm having trouble updating a virtual switch. I added a function to update a switch device but the domoticz switch itself doesn't update.
Below are all my modifications in case it helps someone, maybe @rjblake can incorporate them into his script once we have them working if others will find this useful?
Code: Select all
$tado_heatdemandIDX = "120"; // Your Domoticz DeviceID for the current Tado Heat Demand
$tado_heating_status = get_heating_status($token_file, $home_id, $zone_id);
$DOMO_update = update_switchdevice($tado_heatdemandIDX, $tado_heating_status, $DOMOIPAddress, $DOMOPort, $Username, $Password, $DOMOUpdate);
function get_heating_status($token_file, $home_id, $zone_id) // Gets Status (Heat Demand On/OFF) for ZoneID
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://my.tado.com/api/v2/homes/$home_id/zones/$zone_id/state");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$file = file_get_contents($token_file, true);
$headers = array();
$headers[] = "Authorization: Bearer $file";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$parsed_json = json_decode(curl_exec($ch), true);
$heatdemand = $parsed_json['activityDataPoints']['heatingPower']['percentage'];
if ($heatdemand > 0)
{$heatingstatus = 'On';}
else
{$heatingstatus = 'Off';}
if (curl_errno($ch))
{
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
return $heatingstatus;
}
function update_switchdevice($idx, $switchstate, $DOMOIPAddress, $DOMOPort, $Username, $Password, $DOMOUpdate) // Updates Domoticz Devices
{
if ($DOMOUpdate == 1)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "http://$Username:$Password@$DOMOIPAddress:$DOMOPort/json.htm?type=command¶m=switchlight&idx=$idx&switchcmd=$switchstate");
curl_exec($ch);
curl_close($ch);
}
}
Not sure what I did but it works now. So the script queries tado api to find out whether or not there is currently a demand for heat and uses this to toggle a DOMO virtual switch. I plan to use that virtual switch to trigger sonoff relays. I've also added a check within the script so that it only updates the switch if the demand has changed, rather than continually updating it, therefore I can use logic like - if switch is off and last update was > 10 mins etc etc etc
-
- Posts: 7
- Joined: Monday 18 January 2016 18:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: [677] Tado thermostat
Would love to see tado supported in domoticz. IFTTT just turns it on/off...
3x Hue Lux, 1x Hue Ambiance, 1x Hue rgbwstrip, 1x Hue Iris, 4x KiKa, KiKa doorbell
Raspberry Pi 3, RFXtrx433 USB
Raspberry Pi 3, RFXtrx433 USB
-
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
Re: [677] Tado thermostat
Nice stuff - I've just seen this post now (bit too damn busy lately). I'll add to the master code on GitHub so others can pick it up as well. Thanksairmarshall wrote: ↑Wednesday 13 September 2017 1:55 Hi Guys, Hopefully you can help me. I wish to use the tado api to find out whether or not tado is current calling for heat and use this to toggle a virtual switch. The end goal is to make 2 set's of electric underfloor heating systems 'smart' by leveraging the power of tado geofencing and heating demand management.
So far I have identified the variable I require and added to the latest version of the script to parse this out as an 'On' or 'Off' variable. However I'm having trouble updating a virtual switch. I added a function to update a switch device but the domoticz switch itself doesn't update.
Below are all my modifications in case it helps someone, maybe @rjblake can incorporate them into his script once we have them working if others will find this useful?
UPDATE 18-9-17Code: Select all
$tado_heatdemandIDX = "120"; // Your Domoticz DeviceID for the current Tado Heat Demand $tado_heating_status = get_heating_status($token_file, $home_id, $zone_id); $DOMO_update = update_switchdevice($tado_heatdemandIDX, $tado_heating_status, $DOMOIPAddress, $DOMOPort, $Username, $Password, $DOMOUpdate); function get_heating_status($token_file, $home_id, $zone_id) // Gets Status (Heat Demand On/OFF) for ZoneID { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://my.tado.com/api/v2/homes/$home_id/zones/$zone_id/state"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); $file = file_get_contents($token_file, true); $headers = array(); $headers[] = "Authorization: Bearer $file"; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $parsed_json = json_decode(curl_exec($ch), true); $heatdemand = $parsed_json['activityDataPoints']['heatingPower']['percentage']; if ($heatdemand > 0) {$heatingstatus = 'On';} else {$heatingstatus = 'Off';} if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close ($ch); return $heatingstatus; } function update_switchdevice($idx, $switchstate, $DOMOIPAddress, $DOMOPort, $Username, $Password, $DOMOUpdate) // Updates Domoticz Devices { if ($DOMOUpdate == 1) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, "http://$Username:$Password@$DOMOIPAddress:$DOMOPort/json.htm?type=command¶m=switchlight&idx=$idx&switchcmd=$switchstate"); curl_exec($ch); curl_close($ch); } }
Not sure what I did but it works now. So the script queries tado api to find out whether or not there is currently a demand for heat and uses this to toggle a DOMO virtual switch. I plan to use that virtual switch to trigger sonoff relays. I've also added a check within the script so that it only updates the switch if the demand has changed, rather than continually updating it, therefore I can use logic like - if switch is off and last update was > 10 mins etc etc etc
-
- Posts: 19
- Joined: Friday 04 August 2017 19:21
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: [677] Tado thermostat
Don't incorporate any changes yet as it's causing problems and I need to troubleshoot. Basically the script is doing what I wanted it to but every time it runs it causes the domoticz eventsystem and openZwave to restart == big problems!
I need to go back to the script as you supply it, test it as is to make sure the same problem doesn't occur, then re-build in my changes....
I need to go back to the script as you supply it, test it as is to make sure the same problem doesn't occur, then re-build in my changes....
-
- Posts: 19
- Joined: Friday 04 August 2017 19:21
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: [677] Tado thermostat
Ok, I am running the script 'as-is' from the git, and it's restarting the eventsystem and OZW everytime it does a JSON update. I've set the update wait to 180s, hence the 3 minute restart!
See http://www.domoticz.com/forum/viewtopic ... 94#p152622 for the log reports.
Can anyone else confirm they are also experiencing this?
Domoticz version: 3.8450 ... but it was also doing it with the latest stable as well.
Why would this be? Do I need to seek assitance in another part of the forum. rjblake, what do you think?
I have a presence detection script running on my router that updates a virtual switch in a very similar manner that doesn't cause this behaviour.
Troubleshooting has led me to believe it's actually a domoticz bug. If I disable the tado temp+humidity process from the script my heat demand switch works fine without crashing the database and causing restarts. More info on the bug here: viewtopic.php?f=6&t=19733
See http://www.domoticz.com/forum/viewtopic ... 94#p152622 for the log reports.
Can anyone else confirm they are also experiencing this?
Domoticz version: 3.8450 ... but it was also doing it with the latest stable as well.
Why would this be? Do I need to seek assitance in another part of the forum. rjblake, what do you think?
I have a presence detection script running on my router that updates a virtual switch in a very similar manner that doesn't cause this behaviour.
Troubleshooting has led me to believe it's actually a domoticz bug. If I disable the tado temp+humidity process from the script my heat demand switch works fine without crashing the database and causing restarts. More info on the bug here: viewtopic.php?f=6&t=19733
-
- Posts: 142
- Joined: Friday 21 October 2016 9:25
- Target OS: NAS (Synology & others)
- Domoticz version:
- Location: Netherlands
- Contact:
Re: [677] Tado thermostat
Hi - been away a bit and just seen this. I have aded this to my script running on Synology (v3.8153) and do not see the problem occuring. Both my Temp+Humidity and Switch device are updating as expected. I will check my logs, but not aware of any crash. What I will change is the constant updating of the switch device each time even if no state change. Doesn't make sense to me to do this, as would rather only see logged changes to the state (i.e. from Off to On and vice versa).
Who is online
Users browsing this forum: No registered users and 1 guest