Controlling Toon [HACKED] from Domoticz

For heating/cooling related questions in Domoticz
Maes
Posts: 4
Joined: Tuesday 05 April 2016 20:45
Target OS: -
Domoticz version:
Contact:

Controlling Toon [HACKED] from Domoticz

Postby Maes » Tuesday 05 April 2016 21:23

Image

Hello all,

This is my first post. I've been reading (silently) for a while, and developing myself.
Recently I've introduced Toon to my Domoticz network. The cool thing here is that this Toon is hacked. I would like to share my experience and scripts.

First a bit of background info:
A while ago I was introduced to Domoticz. After buying the Aeon Z-Wave USB stick and a couple of Z-wave devices, I wanted to connect my thermostat.
Because I was using the Honeywell Chronoterm this was impossible.
Soon after I decided to buy a second-hand Toon. After receiving the package and installing the device I was quickly confronted with my own stupidity: I didn't research enough about the Toon and discovered that a second-hand Toon is basically useless. I could not install the device as I did not have the registration key. This resulted in the inability of completing the installation wizard, and only being able to control the temperature with the +/- buttons. Not only that, but I was unable to control the Toon from Domoticz, or any other software for that matter.
This was obviously a (major) set back from the Chronoterm I had been using.

All of these features on the Toon will be unlocked once you purchase a subscription from Eneco (€5 a month if you're not a client). This seemed to be an obvious solution but unfortunately, Eneco doesn't sell these subscriptions to people with a second-hand Toon.
The situation seemed dire.

After (a lot) of research, I came to discover that I was not the only one in this predicament.
http://www.domoticaforum.eu/viewtopic.php?f=17&t=8743&p=79224&hilit=toon+domotica#p79224

This seemed to be the ultimate solution: Rooting/hacking the Toon. Completely going around Eneco.
Of course I wanted to do this but I did not have the proper knowledge to execute (the quite carefully explained) instructions on the above link.
After contacting the inventor of this hack, he quickly replied telling me he was glad to help.
So big big big thanks and all credit goes to marcelr.

So, now I had a hacked Toon. I was able to use the Toon as it was intended, including the programs, etc. etc. But since I doubt there are more than 10 of these hacked Toons in the Netherlands, I didn't really have the proper documentation on how to use the device in combination with Domoticz.
I did research, tested a lot, tested some more, and finally came up with the solutions as it is currently implemented in Domoticz.

Sorry for the long story, I will go on to explain the solution in Domoticz, sharing it for all to use.

Step 1: Controlling the Toon from Domoticz
Requirements;
  • Hacked Toon
  • Open Toon firewall
  • Preconfigured port (in my case port 80)

Start with creating the necessary user variables:
Image

  • All variables that end with "SensorName" are intended to make the scripts a little bit more flexible. Just enter the names of your devices in these variables
  • ToonIP - doesn't need explanation
  • ToonChangedByDomoticz - Unfortunately one of my Toon scripts triggers another, I use this UV to stop this from happening.

Now create the proper devices:
Image

Image

Image

Toon Temperature, Toon Thermostat and Toon Program Information are dummy devices.

Obviously the 2 selector switches operate themselves.

Now the script to operate the setpoint "Toon Thermostat", it's a lua script triggered by device:

Code: Select all

-- Script used for Toon Thermostaat utility device, upon changing temp in Domoticz, temperature is sent to Toon.
--
commandArray = {}

    ToonThermostatSensorName = uservariables['UV_ToonThermostatSensorName'] -- Sensor showing current setpoint
    ToonIP = uservariables['UV_ToonIP']
   
    for deviceName,deviceValue in pairs(devicechanged) do
        if (deviceName == ToonThermostatSensorName) then
            if uservariables['UV_ToonChangedByDomoticz'] == 1 then
                commandArray['Variable:UV_ToonChangedByDomoticz'] = '0'
            else
                SetPoint = otherdevices_svalues[ToonThermostatSensorName]
                ToonCommand = string.format('http://%s/happ_thermstat?action=setSetpoint&Setpoint=%s', ToonIP, SetPoint*100)
               
                print('Setting Toon setpoint to '.. SetPoint)
                commandArray['OpenURL'] = ToonCommand
            end
        end
    end

return commandArray


Step 2: Syncing the Toon with Domoticz (in case of physical interaction on the device, or perhaps one of your switches will initiate additional commands on the toon.
The script. It's a time script that runs every minute:

Code: Select all

-- Time script runs every minute, intended to sync Domoticz with Toon in case the value is changed on the physical device.
-- Updates Toon Thermostat Sensor to value set on Toon
-- Updates Toon Temperature Sensor to value set on Toon
-- Updates Toon Scenes switch based on program set on Toon
-- Updates Toon Auto Program switch to value set on Toon
-- Updates Toon program information text to value set on Toon

commandArray = {}

    ToonThermostatSensorName = uservariables['UV_ToonThermostatSensorName'] -- Sensor showing current setpoint
    ToonTemperatureSensorName = uservariables['UV_ToonTemperatureSensorName'] -- Sensor showing current room temperature
    ToonScenesSensorName  = uservariables['UV_ToonScenesSensorName'] -- Sensor showing current program
    ToonAutoProgramSensorName = uservariables['UV_ToonAutoProgramSensorName'] -- Sensor showing current auto program status
    ToonProgramInformationSensorName = uservariables['UV_ToonProgramInformationSensorName'] -- Sensor showing displaying program information status
    ToonIP = uservariables['UV_ToonIP']
    DomoticzIP = uservariables['UV_DomoticzIP']

    json = assert(loadfile "C:\\Program Files (x86)\\Domoticz\\scripts\\lua\\json.lua")()  -- For Windows
   
    local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
        local ThermostatInfo = handle:read('*all')
    handle:close()
   
    jsonThermostatInfo = json:decode(ThermostatInfo)
   
    currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
    currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
    currentProgramState = tonumber(jsonThermostatInfo.programState)
    currentActiveState = tonumber(jsonThermostatInfo.activeState)
    currentNextTime = jsonThermostatInfo.nextTime
    currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
   
    -- Update the thermostat sensor to current setpoint
    if otherdevices_svalues[ToonThermostatSensorName]*100 ~= currentSetpoint*100 then 
        print('Updating thermostat sensor to new set point: ' ..currentSetpoint)
        commandArray[1] = {['Variable:UV_ToonChangedByDomoticz'] = '1'} -- Set variable changed to 1 to prevent script ToonSetPoint from shooting an event at Toon
        commandArray[2] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonThermostatSensorName], currentSetpoint)}
    end
   
    -- Update the temperature sensor to current room temperature
    if otherdevices_svalues[ToonTemperatureSensorName]*100 ~= currentTemperature*100 then
        print('Updating the temperature sensor to new value: ' ..currentTemperature)
        commandArray[3] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonTemperatureSensorName], currentTemperature)}
    end
   
    -- Update the toon scene selector sensor to current program state
    CurrentToonScenesSensorValue = otherdevices_svalues[ToonScenesSensorName]
   
    if currentActiveState == -1 then currentActiveState = '50' -- Manual
    elseif currentActiveState == 0 then currentActiveState = '40' -- Comfort
    elseif currentActiveState == 1 then currentActiveState = '30' -- Home
    elseif currentActiveState == 2 then currentActiveState = '20' -- Sleep
    elseif currentActiveState == 3 then currentActiveState = '10' -- Away
    end
   
    if CurrentToonScenesSensorValue ~= currentActiveState then  -- Update toon selector if it has changed
        print ('Updating Toon Scenes selector')
        commandArray[4] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonScenesSensorName], currentActiveState)}
    end
   
    -- Updates the toon auto program switch
    CurrentToonAutoProgramSensorValue = otherdevices_svalues[ToonAutoProgramSensorName]
   
    if currentProgramState == 0 then currentProgramState = '10' -- No
    elseif currentProgramState == 1 then currentProgramState = '20' -- Yes
    elseif currentProgramState == 2 then currentProgramState = '30' -- Temporary       
    end
   
    if CurrentToonAutoProgramSensorValue ~= currentProgramState then -- Update toon auto program selector if it has changed
        print ('Updating Toon Auto Program selector')
        commandArray[5] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonAutoProgramSensorName], currentProgramState)}
    end
   
    -- Updates the toon program information text box
    CurrentToomProgramInformationSensorValue = otherdevices_svalues[ToonProgramInformationSensorName]
    if currentNextTime == 0 or currentNextSetPoint == 0 then
        ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°'
    else
        ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°'
    end
   
    if CurrentToomProgramInformationSensorValue ~= ToonProgramInformationSensorValue then
        commandArray[6] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonProgramInformationSensorName], ToonProgramInformationSensorValue)}
    end
       
--

return commandArray


And voila! You now have a fully working Toon with Domoticz. Most importantly, you don't have to pay sh*t to Eneco.
I have tried to program the script and configure the selector switches in such a way that it is intuitive to operate, and identical to operation on the Toon. If you are familiar with the operation of the Toon then these scripts and devices should make sense to you. If you have any further questions please don't hesitate to ask.

Problems:
Unfortunately my Time script triggers the device script when updating the thermostat with the new setpoint. Because I used a user variable to stop this from happening, it is essentially not a problem. However I get warnings in my log that the script has been running for more than 10 seconds. This ONLY happens when the thermostat is updating the setpoint. If anybody knows a more efficient way of stopping the device script from being triggered, and thus removing the warning from my log, I would be very happy.
Image

marcelr
Posts: 57
Joined: Friday 22 May 2015 21:10
Target OS: Linux
Domoticz version: svn 2470
Location: Ehv, NL
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby marcelr » Tuesday 05 April 2016 21:44

I doubt there are more than 10 of these hacked Toons in the Netherlands

I know of at least 12 rooted devices currently existing :-).

So big big big thanks and all credit goes to marcelr.

Actually, most of the hard work was done by Ierlandfan at domoticaforum.eu, and quite a bunch of other members of that forum.

Good luck with your device, I also have "Zon op Toon" working now. It was a good trade ;-), and I learned some new things about newer toons ;-).

grtz,

marcelr
Last edited by marcelr on Tuesday 05 April 2016 21:54, edited 2 times in total.

Maes
Posts: 4
Joined: Tuesday 05 April 2016 20:45
Target OS: -
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby Maes » Tuesday 05 April 2016 21:47

Hey Marcel :)

Yeah, I know. But you get all the credit for helping me!
Good luck with Zon op Toon :D ;)

Maes
Posts: 4
Joined: Tuesday 05 April 2016 20:45
Target OS: -
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby Maes » Tuesday 05 April 2016 21:59

marcelr wrote:
I doubt there are more than 10 of these hacked Toons in the Netherlands

I know of at least 12 rooted devices currently existing :-).


Are 6 of those yours? ;) ;) :lol:

marcelr
Posts: 57
Joined: Friday 22 May 2015 21:10
Target OS: Linux
Domoticz version: svn 2470
Location: Ehv, NL
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby marcelr » Tuesday 05 April 2016 22:11

Nope, I have some 8-) , but not that many.

grtz,

marcelr

hayman
Posts: 12
Joined: Tuesday 15 March 2016 19:08
Target OS: NAS (Synology & others)
Domoticz version: 3.4834
Location: Nerthland
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby hayman » Tuesday 03 May 2016 15:41

marcelr is the best with his help i've rooted TOON which i bought on MP ,,,very happy with it thank alot,know will play buy adding it to my Domoticz,all help are welcome,



thanX

hansworst
Posts: 33
Joined: Tuesday 02 June 2015 23:58
Target OS: Linux
Domoticz version: 3.5114
Location: Woerden / Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby hansworst » Wednesday 11 May 2016 16:53

Is it possible to enable / disable the Auto Program from the Toon without rooting it ? I've searched and searched, and know the JSON stuff to change from Home/Sleep, Setpoint etc, but I can't find how to enable/disable the Auto Program... :( I believe it used to be in the toonopafstand.eneco.nl , but even there the option seems to have disappeared..

I'm (still) a pying Eneco customer and do not neccesarily want to root the Toon...but if this enables met to enable/disable the Auto Program.....maybe I should :)

I'd love to have the same "Auto Program" Selector in Domoticz as Maes :)

robson
Posts: 1
Joined: Thursday 01 September 2016 20:16
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby robson » Thursday 01 September 2016 20:59

Hi. Your post got me to buy a second hand Toon to control from Domoticz. With the help of Marcelr I got my Toon rooted. Hooked it up to Domoticz, and I can control the temperature. But the LUA / JSON script is generating this error:

Error: EventSystem: in Toon sync: /home/pi/domoticz/scripts/lua/JSON.lua:980: /home/pi/domoticz/scripts/lua/JSON.lua:631: expected string's opening quote at char 343 of: {"result":"ok", "currentTemp":"2256", "currentSetpoint":"1500", "currentInternalBoilerSetpoint":"6", "programState":"0", "activeState":"2", "nextProgram":"-1", "nextState":"-1", "nextTime":"0","nextSetpoint":"0","randomConfigId":"1804289383","errorFound":"255","connection":"0","burnerInfo":"0","otCommError":"0","currentModulationLevel":"0",}

It seems to read the values from Toon, but in a wrong format? Any suggestions to get the script working?

Ewout51
Posts: 2
Joined: Monday 22 August 2016 22:40
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby Ewout51 » Tuesday 13 September 2016 21:43

Hello,

I'am new here. But i also have a TOON on the wall, but last year i switched between energy suppliers, so now i dont have any Eneco support on it.
Since a few weeks i'am working with Domoticz on an Raspberry, great system! So i would really like to get in contact with Marcel :D but this forum wont let me send him a private message. :?:

User avatar
G3rard
Posts: 671
Joined: Wednesday 04 March 2015 23:15
Target OS: Linux
Domoticz version: V3.6745
Location: The Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby G3rard » Tuesday 13 September 2016 22:01

Ubuntu Server 14.04 | Domoticz v3.6745 | RFXtrx433E | Z-Wave Aeotec Z-Stick S2
Frontpage | Sonos | Dark th3me | Sony Bravia Python plugin

cvdpol01
Posts: 2
Joined: Tuesday 08 November 2016 10:51
Target OS: -
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby cvdpol01 » Tuesday 08 November 2016 11:00

Hello Meas,
I read your topic and start to implement it on my domoticz and Toon. Both switches are working, but the other sensors not. How can I create these?
I create a dummy device and after that I create virtual sensors, but then?
Can you help me to get it working in my domoticz?

Found it. Where to put the lua script wasn't clear for me. But I found it. Add the scripts in Setup/More options/Events
So, it is working now.

BertusBeensteen
Posts: 1
Joined: Thursday 10 November 2016 17:02
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby BertusBeensteen » Thursday 10 November 2016 17:12

Somehow i can't manage to get it working.
When i set the thermostat setpoint, the toon responds in the right way, but the syncing script returns errors.

Code: Select all

Error: EventSystem: in Toon: [string "-- Time script runs every minute, intended to..."]:26: attempt to index global 'jsonThermostatInfo' (a nil value)


Any idea why?

Edit:
I switched from windows to a raspberry, and after some adjustment, it now works.
It still gave an error on line 41 though because te temperature variable was still at 0, so i set that to 10 in domoticz, and adjusted the script to this:

Code: Select all

-- Time script runs every minute, intended to sync Domoticz with Toon in case the value is changed on the physical device.
-- Updates Toon Thermostat Sensor to value set on Toon
-- Updates Toon Temperature Sensor to value set on Toon
-- Updates Toon Scenes switch based on program set on Toon
-- Updates Toon Auto Program switch to value set on Toon
-- Updates Toon program information text to value set on Toon

commandArray = {}

    ToonThermostatSensorName = uservariables['UV_ToonThermostatSensorName'] -- Sensor showing current setpoint
    ToonTemperatureSensorName = uservariables['UV_ToonTemperatureSensorName'] -- Sensor showing current room temperature
    ToonScenesSensorName  = uservariables['UV_ToonScenesSensorName'] -- Sensor showing current program
    ToonAutoProgramSensorName = uservariables['UV_ToonAutoProgramSensorName'] -- Sensor showing current auto program status
    ToonProgramInformationSensorName = uservariables['UV_ToonProgramInformationSensorName'] -- Sensor showing displaying program information status
    ToonIP = uservariables['UV_ToonIP']
    DomoticzIP = uservariables['UV_DomoticzIP']

    json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()  -- For Raspberry
   
    local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
        local ThermostatInfo = handle:read('*all')
    handle:close()
   
    jsonThermostatInfo = json:decode(ThermostatInfo)
   
    currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
    currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
    currentProgramState = tonumber(jsonThermostatInfo.programState)
    currentActiveState = tonumber(jsonThermostatInfo.activeState)
    currentNextTime = jsonThermostatInfo.nextTime
    currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
   
    -- Update the thermostat sensor to current setpoint
    if otherdevices_svalues[ToonThermostatSensorName]*100 ~= currentSetpoint*100 then 
        print('Updating thermostat sensor to new set point: ' ..currentSetpoint)
        commandArray[1] = {['Variable:UV_ToonChangedByDomoticz'] = '1'} -- Set variable changed to 1 to prevent script ToonSetPoint from shooting an event at Toon
        commandArray[2] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonThermostatSensorName], currentSetpoint)}
    end
   
    -- Update the temperature sensor to current room temperature
    if otherdevices_svalues[ToonTemperatureSensorName]*100 ~= currentTemperature then
        print('Updating the temperature sensor to new value: ' ..currentTemperature)
        commandArray[3] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonTemperatureSensorName], currentTemperature)}
    end
   
    -- Update the toon scene selector sensor to current program state
    CurrentToonScenesSensorValue = otherdevices_svalues[ToonScenesSensorName]
   
    if currentActiveState == -1 then currentActiveState = '50' -- Manual
    elseif currentActiveState == 0 then currentActiveState = '40' -- Comfort
    elseif currentActiveState == 1 then currentActiveState = '30' -- Home
    elseif currentActiveState == 2 then currentActiveState = '20' -- Sleep
    elseif currentActiveState == 3 then currentActiveState = '10' -- Away
    end
   
    if CurrentToonScenesSensorValue ~= currentActiveState then  -- Update toon selector if it has changed
        print ('Updating Toon Scenes selector')
        commandArray[4] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonScenesSensorName], currentActiveState)}
    end
   
    -- Updates the toon auto program switch
    CurrentToonAutoProgramSensorValue = otherdevices_svalues[ToonAutoProgramSensorName]
   
    if currentProgramState == 0 then currentProgramState = '10' -- No
    elseif currentProgramState == 1 then currentProgramState = '20' -- Yes
    elseif currentProgramState == 2 then currentProgramState = '30' -- Temporary       
    end
   
    if CurrentToonAutoProgramSensorValue ~= currentProgramState then -- Update toon auto program selector if it has changed
        print ('Updating Toon Auto Program selector')
        commandArray[5] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonAutoProgramSensorName], currentProgramState)}
    end
   
    -- Updates the toon program information text box
    CurrentToomProgramInformationSensorValue = otherdevices_svalues[ToonProgramInformationSensorName]
    if currentNextTime == 0 or currentNextSetPoint == 0 then
        ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°'
    else
        ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°'
    end
   
    if CurrentToomProgramInformationSensorValue ~= ToonProgramInformationSensorValue then
        commandArray[6] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonProgramInformationSensorName], ToonProgramInformationSensorValue)}
    end
       
--

return commandArray

francisb
Posts: 12
Joined: Wednesday 09 December 2015 22:29
Target OS: -
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby francisb » Tuesday 15 November 2016 21:04

Hi Maes,

I have hacked my Toon also and hooking it up with my Domoiticz on my PI.
I managed to get the Toon Scenes up and running, but your tutorial is bit vage about the dummy devices for Toon temperature, Toon thermostat and Toon Program Information.

What type of Dummy did you create and how did you add the LUA script to these?

Regards,


Francis
Raspberry Pi 2B, rfxcom rfxtrx433e, COCO switches, oregon scientific temp/hum sensors, Foscam 8904W, Foscam 9821W v2,

cvdpol01
Posts: 2
Joined: Tuesday 08 November 2016 10:51
Target OS: -
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby cvdpol01 » Tuesday 22 November 2016 10:50

Hi Francisb,

The lua script should be added in domotics -> Setup/More options/Events
Be aware, the script of Maes is for windows systems. The following should be change in

json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Raspberry

For the devices, you have to create a dummy device, name is not important.On that dummy device you have to create virual sensors. Toon Thermostat and Toon Temperature are temperature sensors and Toon Program Information is a texst sensor.

adjego
Posts: 37
Joined: Monday 16 February 2015 12:42
Target OS: Raspberry Pi
Domoticz version: V3.5163
Location: Eindhoven
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby adjego » Friday 02 December 2016 11:34

Nice work.

I have this working for my Domoticz aswell!
I did however needed to "fix" the json data which somes from Toon. It had an error in it.

Added this:

Code: Select all

local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
   local ThermostatInfo = handle:read('*all')
handle:close()

-- JSON data from Toon contains a extra "," which should not be there.
ThermostatInfo = string.gsub(ThermostatInfo, ",}", "}")

jsonThermostatInfo = json:decode(ThermostatInfo)


Next to that i like to be able to also control lights which are in domoticz via Toon.
Somebody here already managed to get this working with some nice buttons?

Timeless
Posts: 35
Joined: Friday 10 June 2016 23:46
Target OS: Linux
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby Timeless » Friday 06 January 2017 12:25

I've looked at the topic the TS posted Link. And it seems that it is easy to make Toon accessible using SSH. But what about displaying information at Toon? Most of the conversation is about using Toon to control Domoticz and using Toon as a sensor. But what about displaying information at Toon?

For example:

I already have a Water/Gas/Energy sensor in my Domoticz setup. Is it possible to show this information from Domoticz ---> Toon? So I can use my existing sensors instead of the Toon sensors? I noticed that Water is not yet supported by Toon, so I'm unsure if that may even work without support from software.

Update:

Mmh. It seems possible to use exiting sensors from non-Toon sensors (like Domoticz): Link But since I do not have a Toon at this participial moment. I cannot test anything myself. And have not seen a detailed how-to which makes me unable to guess the difficulty level.

Update2:
Someone tried to make a basic widget using qt, this could be helpfull: link

Update3:
There is also a topic about custom widgets for Toon: link and very promising
"The greatest good you can do for another, is not to share your own riches, but to reveal to him, his own."
- Benjamin Disraeli -

Timeless
Posts: 35
Joined: Friday 10 June 2016 23:46
Target OS: Linux
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby Timeless » Sunday 08 January 2017 19:58

It seems that there is some kind of leak in the script. Because after +/-50min Domoticz freezes. When I check the logs I see that several of my hardware (threads) exit unexpectedly. After a while Domoticz stops completely.

Maybe it has something to do with the variables used? shouldn't they be local? If I understand LUA correctly a Local variable is gone when a block exits. So that is exactly what we need?

Most of the variables are placed in the _G table which is not necessary. If we keep them local then they are deleted(free) when the script is done. This should not leak any memory.

As said I'm not a LUA language guy. So this could also be my C or C++ mind talking :). But locals are also faster: link which is also a pro.

EDIT2:
Maybe I found the cause for "script has been running for more than 10sec"
I think that changing the "switcher" value causes a JSON SET action to Toon by the actual Switcher button. So when the LUA script updates "Toon Scenes" the switcher then sends the configured URL to Toon. It is currently just a theory, maybe we can try to enter a non-matching URL so when updating the Switcher will actually send a different scene to be activated.
Last edited by Timeless on Monday 27 March 2017 21:15, edited 1 time in total.
"The greatest good you can do for another, is not to share your own riches, but to reveal to him, his own."
- Benjamin Disraeli -

helppp
Posts: 1
Joined: Thursday 12 January 2017 13:48
Target OS: Linux
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby helppp » Thursday 12 January 2017 13:56

I hope it is fine to ask this, if not please let me know. I have been looking for an Eneco Toon for some time now. What I want is to use it as thermostat but show on the display a webbrowser. Anybody knows if this is possible? It is running Linux I think?

R0cc0
Posts: 8
Joined: Monday 26 January 2015 10:11
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby R0cc0 » Wednesday 22 February 2017 15:17

I need a little help with setting this up.
I have the switches working but the script is still giving me errors

2017-02-22 14:13:00.563 Error: EventSystem: in ToonSync: [string "-- Time script runs every minute, intended to..."]:39: attempt to perform arithmetic on field '?' (a nil value)
I think it has to do with the virtual sensors but I'm not 100% sure I set them up correctly

I'm running on Raspberry so I decided to use adjego's script but still no go...

QuasaR
Posts: 19
Joined: Tuesday 15 July 2014 17:13
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Postby QuasaR » Friday 03 March 2017 13:05

R0cc0 wrote:I need a little help with setting this up.
I have the switches working but the script is still giving me errors

2017-02-22 14:13:00.563 Error: EventSystem: in ToonSync: [string "-- Time script runs every minute, intended to..."]:39: attempt to perform arithmetic on field '?' (a nil value)
I think it has to do with the virtual sensors but I'm not 100% sure I set them up correctly

I'm running on Raspberry so I decided to use adjego's script but still no go...


Try this script:

Code: Select all

-- Time script runs every minute, intended to sync Domoticz with Toon in case the value is changed on the physical device.
-- Updates Toon Thermostat Sensor to value set on Toon
-- Updates Toon Temperature Sensor to value set on Toon
-- Updates Toon Scenes switch based on program set on Toon
-- Updates Toon Auto Program switch to value set on Toon
-- Updates Toon program information text to value set on Toon

commandArray = {}

    ToonThermostatSensorName = uservariables['UV_ToonThermostatSensorName'] -- Sensor showing current setpoint
    ToonTemperatureSensorName = uservariables['UV_ToonTemperatureSensorName'] -- Sensor showing current room temperature
    ToonScenesSensorName  = uservariables['UV_ToonScenesSensorName'] -- Sensor showing current program
    ToonAutoProgramSensorName = uservariables['UV_ToonAutoProgramSensorName'] -- Sensor showing current auto program status
    ToonProgramInformationSensorName = uservariables['UV_ToonProgramInformationSensorName'] -- Sensor showing displaying program information status
    ToonIP = uservariables['UV_ToonIP']
    DomoticzIP = uservariables['UV_DomoticzIP']

    json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()

    local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
        local ThermostatInfo = handle:read('*all')
    handle:close()

    jsonThermostatInfo = json:decode(ThermostatInfo)

    currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
    currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
    currentProgramState = tonumber(jsonThermostatInfo.programState)
    currentActiveState = tonumber(jsonThermostatInfo.activeState)
    currentNextTime = jsonThermostatInfo.nextTime
    currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100

    -- Update the thermostat sensor to current setpoint
    if otherdevices_svalues[ToonThermostatSensorName]*100 ~= currentSetpoint*100 then
        print('Updating thermostat sensor to new set point: ' ..currentSetpoint)
        commandArray[1] = {['Variable:UV_ToonChangedByDomoticz'] = '1'} -- Set variable changed to 1 to prevent script ToonSetPoint from shooting an event at Toon
        commandArray[2] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonThermostatSensorName], currentSetpoint)}
    end

    -- Update the temperature sensor to current room temperature
    if otherdevices_svalues[ToonTemperatureSensorName]*100 ~= currentTemperature*100 then
        print('Updating the temperature sensor to new value: ' ..currentTemperature)
        commandArray[3] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonTemperatureSensorName], currentTemperature)}
    end

    -- Update the toon scene selector sensor to current program state
    CurrentToonScenesSensorValue = otherdevices_svalues[ToonScenesSensorName]

    if currentActiveState == -1 then currentActiveState = '50' -- Manual
    elseif currentActiveState == 0 then currentActiveState = '40' -- Comfort
    elseif currentActiveState == 1 then currentActiveState = '30' -- Home
    elseif currentActiveState == 2 then currentActiveState = '20' -- Sleep
    elseif currentActiveState == 3 then currentActiveState = '10' -- Away
    end

    if CurrentToonScenesSensorValue ~= currentActiveState then  -- Update toon selector if it has changed
        print ('Updating Toon Scenes selector')
        commandArray[4] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonScenesSensorName], currentActiveState)}
    end

    -- Updates the toon auto program switch
    CurrentToonAutoProgramSensorValue = otherdevices_svalues[ToonAutoProgramSensorName]

    if currentProgramState == 0 then currentProgramState = '10' -- No
    elseif currentProgramState == 1 then currentProgramState = '20' -- Yes
    elseif currentProgramState == 2 then currentProgramState = '30' -- Temporary
    end

    if CurrentToonAutoProgramSensorValue ~= currentProgramState then -- Update toon auto program selector if it has changed
        print ('Updating Toon Auto Program selector')
        commandArray[5] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonAutoProgramSensorName], currentProgramState)}
    end

    -- Updates the toon program information text box
    CurrentToomProgramInformationSensorValue = otherdevices_svalues[ToonProgramInformationSensorName]
    if currentNextTime == 0 or currentNextSetPoint == 0 then
        ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°'
    else
        ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°'
    end

    if CurrentToomProgramInformationSensorValue ~= ToonProgramInformationSensorValue then
        commandArray[6] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonProgramInformationSensorName], ToonProgramInformationSensorValue)}
    end

--

return commandArray


Return to “Heating/cooling”

Who is online

Users browsing this forum: No registered users and 3 guests