Toon as a domotica controller?

Everything about rooting Toons 1 and 2.

Moderators: marcelr, TheHogNL, Toonz

Post Reply
iMars
Starting Member
Starting Member
Posts: 17
Joined: Tue Nov 17, 2015 10:47 pm

Re: Toon as a domotica controller?

Post by iMars »

I've got a Toon and would love to use it in Domiticz (without the need of an Eneco account). Reading the current and set temperature and changing to 1 of the 4 presets would be enough for me (more is alway nice such as controlling hue lights). I'm following this topic every day and I'm excited for the progress.
Boraxx
Starting Member
Starting Member
Posts: 2
Joined: Tue Nov 24, 2015 11:50 am

Re: Toon as a domotica controller?

Post by Boraxx »

@MarcelR looking to interface with Raspberry Pi based sensors around the house and the garden, as well as being able to open the garage door and some other things.
All PiDome based. But want it all to converge into the TOON as a central hub in the house.

Also btw, does anybody know what happens if I were to accidently break the TOON's authentiation credentials for the VPN to Eneco?
Does it fix itsself, or will it break permanently(ie stay away from the Quby software?
marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Toon as a domotica controller?

Post by marcelr »

Also btw, does anybody know what happens if I were to accidently break the TOON's authentiation credentials for the VPN to Eneco?
Does it fix itsself, or will it break permanently(ie stay away from the Quby software?
The credentials are a combination of a server and client key. If you screw up the client key (and you don't have the server key) that's the end of it AFAIK. No chance of getting it fixed without the help of Quby or Eneco.

Not sure if toon hardware can sustain a jvm for PiDome at a reasonable speed (128MB RAM, 400MHz ARM-926EJS).

grtz,

marcelr
Last edited by marcelr on Thu Dec 03, 2015 7:28 pm, edited 1 time in total.
Ierlandfan
Member
Member
Posts: 151
Joined: Thu Oct 03, 2013 7:53 pm

Re: Toon as a domotica controller?

Post by Ierlandfan »

Santa is early this year :-)

Disclaimer:
I am not responsible for breaking your Toon, breaking you cv,
burning your house, wrecking your computer, huge gas or electricity bills,
cold winters because you did something stupid, complaing girlfriends or wives/kids, divorce
or you for doing something you shouldn't be doing.


Attached is the way to root Toon. Scripts and small Domoticz tutorial will be uploaded later.
It's tested but use your head anyway, don't simply copy/paste.
Think first. Or stop and ask here if something is not clear. Winter can be cold.

Credits where credits are due:
MarcelR: for starting this topic, for the patience with my php skills, helping me with tips, comments and routines and the php arrays so Toon spits out human readible Opentherm data in json format. (You really coded some parts in the cloud(s)!)
(Transferring php skills MarcelR to Ierlandfan. Error 404: routine not found..darn)
He also wrote the English tutorial I just uploaded. I added and edited some small parts for clarity.

Schelte: for testing, tips, comments and for the development of the OTGW which paved the way into Opentherm data.
Mister Anonymous: for a few php ideas.

And last but not least a warm special thanx to the folks at Quby for making such a great device
and letting us explore Toon this way.

Enjoy!
Attachments
Toonroot.rar
(5.75 KiB) Downloaded 1335 times
User avatar
RDNZL
Forum Moderator
Forum Moderator
Posts: 1008
Joined: Sun Sep 24, 2006 1:45 pm
Location: Dordrecht, The Netherlands
Contact:

Re: Toon as a domotica controller?

Post by RDNZL »

Thanks!

But the editing of the binary part can be replaced by just two commands (sorry ;-))
Simply login as root and type:

Fix:

Code: Select all

echo "127.0.0.1 ping.quby.nl" >>/etc/hosts.template
reboot
Check:

Code: Select all

eneco-001-xxxxxx:/# ping ping.quby.nl
PING ping.quby.nl (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=1.108 ms
64 bytes from 127.0.0.1: seq=1 ttl=64 time=0.738 ms
64 bytes from 127.0.0.1: seq=2 ttl=64 time=0.658 ms
Looking forward to your php code!
Regards, Ron.
wwolkers
Member
Member
Posts: 273
Joined: Tue Sep 23, 2008 10:10 am
Location: Netherlands
Contact:

Re: Toon as a domotica controller?

Post by wwolkers »

Nice!

really looking forward to the post of tomorrow and the php code!
marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Toon as a domotica controller?

Post by marcelr »

Finally made it into the great wide open!

good job, ierlandfan.

edit:
(You really coded some parts in the cloud(s)!)
What else can you do on long, boring, transatlantic flights, besides deciding between chicken and pasta? :-)

For those of you who cannot build the openembedded tree (or cannot wait for the build to complete; it takes forever :-)): Here's the dropbear installation file for toon. Unzip, upload to toon (see toonroot.txt how to do that), and install with:

Code: Select all

opkg install dropbear_0.51-r7.0_qb2.ipk
EDIT: This file is no longer available, please use the later version of dropbear:
http://www.domoticaforum.eu/viewtopic.p ... 240#p78984

grtz,

marcelr
Last edited by marcelr on Tue Mar 01, 2016 8:34 pm, edited 1 time in total.
Ierlandfan
Member
Member
Posts: 151
Joined: Thu Oct 03, 2013 7:53 pm

Re: Toon as a domotica controller?

Post by Ierlandfan »

Some background to make Domoticz work:

You need to open port 7080 in the iptables.conf (See toonroot.txt)
I always reboot afterwards to reload the iptables but there's a way of reloading the iptables without reboot
but well, reboot works fine.

By the way, you need to edit the iptables.conf every time Toon is software updated (And so SSH is again firewalled)
So better way is to make a custom start-up script which modifies the iptables every time Toon reboots. Multiple ways of doing that. If anyone wants to write that part, "go your gang" as some soccer trainer probably will say some day.

After the iptables are ok you have to enable this special webinterface since it's not the same as the one that comes default with the Toon. For that you have to edit this part in \HCBv2\config\hcb_project.xml into something like this:

Code: Select all

                <!-- Release uses lighttpd; put hcb_web somewhere where its harmless -->
                <port>7080</port>
                <defaultEntry>/HCBv2/www/</defaultEntry>
                <enforceWhitelist>0</enforceWhitelist>
    <whitelist>
        <item>hdrv_zwave</item>
    </whitelist>
You probably have to restart some service but I always reboot since I never bothered what service to restart.
Not sure whether a

Code: Select all

chmod -R 755 \HCBv2\www  
is needed.
If anyone can confirm this, that would be great.

If everything went fine you can connect to Toon by using your browser
Try this for example:

Code: Select all

 http://ip_toon:7080/happ_thermstat?action=printTableInfo
( change the part http://ip_toon/ to your Toon IP)
If that works, continue

So now if everything went well we have a API like interface to connect to wich spits out valuable info.
I won't go into detail about every webhandler but you can find almost all of them by using

Code: Select all

strings -f \HCBv2\sbin\<binary-name> |grep web
In case of Domotica we want:

Code: Select all

http://ip_toon:7080/happ_thermstat?action=printTableInfo 
These are the Opentherm dataID's with the corresponing values in not very handy human readible format.
(I'll get back on this)
We also want this:

Code: Select all

 http://ip_toon:7080/happ_pwrusage?action=GetCurrentUsage 
That's Electricity Usage. Something that is not working for the Domoticz Toon op afstand Domoticz plugin
I also use this one:

Code: Select all

http://ip_toon:7080/hdrv_zwave?action=getDevices.json
because I have a smoke detector and a Fibaro Smart plug.
Things like setting the temperature is done through Toon op afstand since I only wanted to monitor this data.

So how to push this data to Domoticz?
We need a few script for this. (Maybe some day I will make one script-to-do-it-all)
OT_data_json.php. This converts the gibberish Opentherm data into human friendly data (and in valid json format..)
E.g.

Code: Select all

{'dataId':'18', 'value0':'01', 'value1':'66', 'updated':'1449186252', 'description':'[ID 18: 01 66]'},,
becomes:

Code: Select all

{"dataId":"18","value":1.3984375,"Timestamp":"Fri 4 Dec 2015 0:44:52"}
(Which means my Waterpressure is currently 1.39 bar)
AGPO uses this value incorrectly as the threshold value for waterpressure but anyway

and it dumps the json file to /tmp/otttableout.txt
This is fed into Domoticz by "domoticz.toon.script"
It takes the values from the json data and pushes them to the http Domoticz API
There almost no error correction (Time...)
Anyway, put those in crontab:
*/1 * * * * /path-to-/OT_data_json.php
*/1 * * * * /path-to/Electricity_data_json.php
*/1 * * * * /path-to/domoticz.toon.script
*/1 * * * * /path-to/rookmelder_data_json.php
Unrar the attached scripts and upload to your Domoticz server
You probably need to do

Code: Select all

chmod +x <script-name> 
to make them executable.
Edit OT_data_json.php and change the part http://IP_Toon/ to your Toon IP.
Edit domoticz.toon.script, change the part http://IP_Toon/ to your Toon IP and change to your idx values and your good to go.

Same thing for Electricity_data_json.php
Same thing for rookmelder_data_json.php

To do: Test the OT data for proper conversion. Probably OK but i never checked it. My AGPO CV is not sending every available value so it's possible there is an error typo/error/conversion-error in those not supported by my HVAC.
The scripts are running fine but will fail silently when an error is encountered
(I never noticed one though in about 4 months)
So to do: Error correction, they now fail silently when not running
To do: Get rid of /tmp/ottableout.txt (Debug legacy)
To do: Make a one-size-fits-all script with all available options and values to query. (Again debug legacy)
To do: Use some optional form of authentication for Domoticz.
To do: replace probably with confirmed...
Enjoy!
Attachments
Domoticz-toon-scripts.rar
(7.39 KiB) Downloaded 824 times
wwolkers
Member
Member
Posts: 273
Joined: Tue Sep 23, 2008 10:10 am
Location: Netherlands
Contact:

Re: Toon as a domotica controller?

Post by wwolkers »

small error in domoticz.toon.script:

$idx73 = 29; OEM-specific code for ventilation and heat recovery (Text) */

should be:

$idx73 = 29; /* OEM-specific code for ventilation and heat recovery (Text) */
Ierlandfan
Member
Member
Posts: 151
Joined: Thu Oct 03, 2013 7:53 pm

Re: Toon as a domotica controller?

Post by Ierlandfan »

Yep, I saw the problem. Late editing problem.
If you want the Opentherm value 113 you have to remove the # in front of line 48.
iMars
Starting Member
Starting Member
Posts: 17
Joined: Tue Nov 17, 2015 10:47 pm

Re: Toon as a domotica controller?

Post by iMars »

WOW :P :P :P That's really some fast progresses in the last few days! Nice!
I've downloaded the scripts and am trying to figure it out how everything is working...
What I can's see, leaves me with a question:
What can you exactly do with Toon after those steps?
Only reading values? Or is it possible to change the temperature and/or program (weg/slapen/thuis/comfort)?

I haven't open my Toon yet, as I'm waiting till everything is confirmed and ready.
I've ordered this serial adapter for some ESP's, I'm assuming this is good enough for Toon (as long as the jumper is on 3.3V mode):
http://nl.aliexpress.com/item/Free-ship ... wVersion=2

Cant wait to make it all work in Domoticz 8)
marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Toon as a domotica controller?

Post by marcelr »

Only reading values? Or is it possible to change the temperature and/or program (weg/slapen/thuis/comfort)?
The weekly program is stored in an xml-file:

/HCBv2/config/config_happ_thermstat.xml

and looks like this (small excerpt, it's quite a file):

Code: Select all

   
....

   <device>
     <schedule>
      <entry type="weekly_recurring">
       <type>weekly_recurring</type>
       <startMin>0</startMin>
       <startHour>8</startHour>
       <startDayOfWeek>0</startDayOfWeek>
       <targetState>1</targetState>
       <endMin>0</endMin>
       <endHour>17</endHour>
       <endDayOfWeek>0</endDayOfWeek></entry>
      <entry type="weekly_recurring">
       <type>weekly_recurring</type>
       <startMin>0</startMin>
       <startHour>17</startHour>
       <startDayOfWeek>0</startDayOfWeek>
       <targetState>0</targetState>
       <endMin>30</endMin>
       <endHour>21</endHour>
       <endDayOfWeek>0</endDayOfWeek></entry>
      <entry type="weekly_recurring">
       <type>weekly_recurring</type>
       <startMin>30</startMin>
       <startHour>21</startHour>
       <startDayOfWeek>0</startDayOfWeek>
       <targetState>2</targetState>
       <endMin>30</endMin>
       <endHour>6</endHour>
       <endDayOfWeek>1</endDayOfWeek></entry>
      <entry type="weekly_recurring">
       <type>weekly_recurring</type>
       <startMin>30</startMin>
       <startHour>6</startHour>
       <startDayOfWeek>1</startDayOfWeek>
       <targetState>1</targetState>
       <endMin>0</endMin>

...
  
By rewriting entries and restarting the thermostat application (happ_thermstat, not sure if it restarts by itself if you change the program, most applications on toon do autorestart) you should be able to remotely override the program settings. targetState in the example is one of the four preset temperatures, and these are set elsewhere in the same file.

Haven't tested this.
I haven't open my Toon yet, as I'm waiting till everything is confirmed and ready.
What needs confirmation?
I've ordered this serial adapter for some ESP's, I'm assuming this is good enough for Toon (as long as the jumper is on 3.3V mode):
http://nl.aliexpress.com/item/Free-ship ... wVersion=2
FTDI chipset (or is it?). Should work. Good deal BTW.

And remember the 11th commandment: Thou shalt make back-ups!
(of your toon's flash memory, that is. dd is your friend).

grtz,

marcelr
marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Toon as a domotica controller?

Post by marcelr »

This summer I made a script to read out the energy databases of toon. If you have some way of presenting them (even MS excel, if all else fails ;-)) this might be useful for you. Unzip, edit some paths, and run with php.

The method to work with this script is described at the top of the file.
As you can see, there's no need to have an Eneco account, all data are stored locally on toon.

enjoy,

marcelr
Attachments
hcb_rrd.php.zip
php script for transforming toon data into human-readable format.
(2.39 KiB) Downloaded 704 times
al_n
Member
Member
Posts: 52
Joined: Tue Jun 02, 2015 7:51 pm

Re: Toon as a domotica controller?

Post by al_n »

WOW,

I just wanted to see if there was any progress on this since my last visit in june, my timing couldn't be better!
I think you guys made a great job!

I have one question: can I just use an older laptop with a serial port with direct wiring of Rx, TX and GND? Or are the voltage levels different?
Can someone attach a photo of the connector side just to be damn sure about this and not screw anything?

Tnx!!
al_n
Member
Member
Posts: 52
Joined: Tue Jun 02, 2015 7:51 pm

Re: Toon as a domotica controller?

Post by al_n »

I guess that the answer to my previous question is "no". You need serial TTL adapter, right?
Post Reply

Return to “Toon Rooting”