Controlling Toon [HACKED] from Domoticz

For heating/cooling related questions in Domoticz

Moderator: leecollings

User avatar
gijsje
Posts: 132
Joined: Saturday 19 August 2017 14:28
Target OS: NAS (Synology & others)
Domoticz version: Stable
Location: Berkel Enschot, NL
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gijsje »

Thanks a lot seems to be working now :D

Image
Synology DS218+ - RFXtrx433 - Aeotec Z-Stick Gen5 - Toon Thermostat - Neo CoolCam plug - Neo CoolCam PIR - FIBARO PIR - Heiman Smart Smoke Senso - Neo CoolCam Leakage Detector - BeNext Tag Reader - P1 and S0 USB - many Mi-Light lights - KAKU switches
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gielie »

I found a bug in the latest gas script.
The gas amount is a 1000 fold too high.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

gielie wrote: Friday 16 March 2018 14:54 I found a bug in the latest gas script.
The gas amount is a 1000 fold too high.
Are you sure? Domoticz uses . instead of ,

For me it's reporting 3.990 m3 today and 1698.031 m3 in total. This is the same on my Toon.
nt1nitro
Posts: 2
Joined: Wednesday 06 May 2015 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by nt1nitro »

I was hoping someone can help me with the following error.

The error is after manual changing the setpoint in domoticz.

2018-03-18 17:04:22.630 dzVents: Info: ------ Start internal script: ToonSetPoint: Device: "Toon Thermostat (Toon Thermostat)", Index: 468
2018-03-18 17:04:22.631 dzVents: Error (2.4.1): An error occured when calling event handler ToonSetPoint
2018-03-18 17:04:22.631 dzVents: Error (2.4.1): ...oticz/scripts/dzVents/generated_scripts/ToonSetPoint.lua:8: attempt to perform arithmetic on field 'SetPoint' (a nil value)
2018-03-18 17:04:22.631 dzVents: Info: ------ Finished ToonSetPoint

Everything with the rooted toon is working EXCEPT manual changing the setpoint. The temp is not changing in the toon display, and after 1 minute the temp is back in domoticz to the previous temp.

I removed multiple times everything, also the variables. I'm using the dvenz scripts.
glsf91
Posts: 58
Joined: Tuesday 14 November 2017 21:56
Target OS: Linux
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by glsf91 »

nt1nitro wrote: Sunday 18 March 2018 17:17 I was hoping someone can help me with the following error.

The error is after manual changing the setpoint in domoticz.

2018-03-18 17:04:22.630 dzVents: Info: ------ Start internal script: ToonSetPoint: Device: "Toon Thermostat (Toon Thermostat)", Index: 468
2018-03-18 17:04:22.631 dzVents: Error (2.4.1): An error occured when calling event handler ToonSetPoint
2018-03-18 17:04:22.631 dzVents: Error (2.4.1): ...oticz/scripts/dzVents/generated_scripts/ToonSetPoint.lua:8: attempt to perform arithmetic on field 'SetPoint' (a nil value)
2018-03-18 17:04:22.631 dzVents: Info: ------ Finished ToonSetPoint

Everything with the rooted toon is working EXCEPT manual changing the setpoint. The temp is not changing in the toon display, and after 1 minute the temp is back in domoticz to the previous temp.

I removed multiple times everything, also the variables. I'm using the dvenz scripts.
There is a mistake in your setpoint script or the name of the device (in variable UV_ToonThermostatSensorName) is wrong. Check this carefully.

My working script:

Code: Select all

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
Also don't forget to put the script on type "Device" in de GUI.
nt1nitro
Posts: 2
Joined: Wednesday 06 May 2015 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by nt1nitro »

Thank you glsf91

I unchecked my dventz lua script , made a new lua with your script in it,
and its working ! Thank you.
I don't understand why, but finaly its working.
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gielie »

FunFair wrote: Friday 16 March 2018 17:22
gielie wrote: Friday 16 March 2018 14:54 I found a bug in the latest gas script.
The gas amount is a 1000 fold too high.
Are you sure? Domoticz uses . instead of ,

For me it's reporting 3.990 m3 today and 1698.031 m3 in total. This is the same on my Toon.
Yes im sure, i have a lua script running which runs great, the power script show exactly the same but the php gas script shows a 1000 fold too high gas usage, how do i know the php is wrong and not the lua, the php script gives me a 3000 M2 gas usage a day and that is a bit too much.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
maikelvds
Posts: 13
Joined: Monday 19 March 2018 15:16
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by maikelvds »

Hi guys,

I'm new on this forum, at least as a member. Did read and learn a lot from this forum so far. I started with Domoticz for my lights etc. After some time I read a lot about the possibilites within Domoticz. So I started with some small scripts. Toon was already in Domoticz, but I paid a lot to Eneco.. I read about it and I want it for free. So a few weeks ago TerrorSource (thanks again) rooted my Toon. Since I'm not a programmer, it is quit difficult for me. Yesterday TerrorSource helped me to get Toon into Domoticz. The next step for me is to get the power and gas usage in Domoticz.

My current situation:
2x raspberry pi 3, Raspberry 1 with domoticz and all my lights, smoke detectors, blinds etc etc. and Raspberry 2 with domoticz only for testing new stuff.

Raspberry 1 and raspberry 2 are not using the same version. That's directly my first remark. When I was reading about the gas and power usage in Domoticz, you have to install php-curl. When I want to do this on Raspberry 1, I only get 'Unable to locate package php-curl'. php5-curl is working... On raspberry 2 php-curl is working, but still no gas/power usage in domoticz.

If I use the scripts on this forum, is it required to use specific name for the switches? I changed the IP adresses and the IDX values but it is still not working.

When I go to for example:
http://TOONIP/happ_pwrusage?action=GetCurrentUsage

It is working, I get:
{"result":"ok",
"powerUsage": {"value":207, "dayCost":1.09, "avgValue":264.03},
"powerProduction": {"value":0, "dayCost":0.00, "avgValue":0.00},
"gasUsage": {"value":15, "dayCost":0.19,"avgValue":178.51}
}
For my feeling I'm missing something smalls, but I don't know what.... Any of you a idea?
rudolfpi
Posts: 8
Joined: Monday 19 March 2018 18:17
Target OS: Linux
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by rudolfpi »

Hello,
Bought a 2nd hand Toon via MP. I want to root it. Where can I find the best instruction to do so?
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

gielie wrote: Monday 19 March 2018 14:45
FunFair wrote: Friday 16 March 2018 17:22
gielie wrote: Friday 16 March 2018 14:54 I found a bug in the latest gas script.
The gas amount is a 1000 fold too high.
Are you sure? Domoticz uses . instead of ,

For me it's reporting 3.990 m3 today and 1698.031 m3 in total. This is the same on my Toon.
Yes im sure, i have a lua script running which runs great, the power script show exactly the same but the php gas script shows a 1000 fold too high gas usage, how do i know the php is wrong and not the lua, the php script gives me a 3000 M2 gas usage a day and that is a bit too much.
Wich values do you see if you open this link?
http://192.168.0.11/hcb_rrd?action=getR ... =20-3-2018

Change your ip ofcourse
Mine reports 20-03-2018 08:00:00": 1720469
And my toon display shows 1720
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

rudolfpi wrote: Monday 19 March 2018 18:19 Hello,
Bought a 2nd hand Toon via MP. I want to root it. Where can I find the best instruction to do so?
https://www.domoticaforum.eu/viewforum.php?f=87
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

maikelvds wrote: Monday 19 March 2018 16:34 Hi guys,

I'm new on this forum, at least as a member. Did read and learn a lot from this forum so far. I started with Domoticz for my lights etc. After some time I read a lot about the possibilites within Domoticz. So I started with some small scripts. Toon was already in Domoticz, but I paid a lot to Eneco.. I read about it and I want it for free. So a few weeks ago TerrorSource (thanks again) rooted my Toon. Since I'm not a programmer, it is quit difficult for me. Yesterday TerrorSource helped me to get Toon into Domoticz. The next step for me is to get the power and gas usage in Domoticz.

My current situation:
2x raspberry pi 3, Raspberry 1 with domoticz and all my lights, smoke detectors, blinds etc etc. and Raspberry 2 with domoticz only for testing new stuff.

Raspberry 1 and raspberry 2 are not using the same version. That's directly my first remark. When I was reading about the gas and power usage in Domoticz, you have to install php-curl. When I want to do this on Raspberry 1, I only get 'Unable to locate package php-curl'. php5-curl is working... On raspberry 2 php-curl is working, but still no gas/power usage in domoticz.

If I use the scripts on this forum, is it required to use specific name for the switches? I changed the IP adresses and the IDX values but it is still not working.

When I go to for example:
http://TOONIP/happ_pwrusage?action=GetCurrentUsage

It is working, I get:
{"result":"ok",
"powerUsage": {"value":207, "dayCost":1.09, "avgValue":264.03},
"powerProduction": {"value":0, "dayCost":0.00, "avgValue":0.00},
"gasUsage": {"value":15, "dayCost":0.19,"avgValue":178.51}
}
For my feeling I'm missing something smalls, but I don't know what.... Any of you a idea?
The php script doesnt need names. Only idxnumbers.
What is the output when you manually run the script?
Is the script executable?
jack75
Posts: 1
Joined: Tuesday 20 March 2018 21:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by jack75 »

thanks for the scripts and help on the forum. I ran in two problems so far that could be easily fixed. one was the addition of the -m 5 to the curl part of the toon get info, because script running too long and domoticz getting unresponsive. Another one was the "local network" setting in domoticz, when using domoticzboard from the Toon to accept json commands when you're not authorized.
maikelvds
Posts: 13
Joined: Monday 19 March 2018 15:16
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by maikelvds »

FunFair wrote: Tuesday 20 March 2018 7:24 The php script doesnt need names. Only idxnumbers.
What is the output when you manually run the script?
Is the script executable?
Thanks for your answer. I will check it next week when I'm back in my network again. To be continued!
Johan1974
Posts: 35
Joined: Monday 04 December 2017 20:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Johan1974 »

Hello,

I used the script:

-- 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



Every minute i have the error :

2018-03-21 21:50:00.330 Error: EventSystem: in ToonSetPoint: [string "-- Script used for Toon Thermostaat utility d..."]:8: bad argument #1 to 'pairs' (table expected, got nil

What is the problem....
glsf91
Posts: 58
Joined: Tuesday 14 November 2017 21:56
Target OS: Linux
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by glsf91 »

Johan1974 wrote: Wednesday 21 March 2018 21:57 Hello,

I used the script:

-- 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



Every minute i have the error :

2018-03-21 21:50:00.330 Error: EventSystem: in ToonSetPoint: [string "-- Script used for Toon Thermostaat utility d..."]:8: bad argument #1 to 'pairs' (table expected, got nil

What is the problem....

You have to save this script as a Device script, not a Time script
Johan1974
Posts: 35
Joined: Monday 04 December 2017 20:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Johan1974 »

glsf91 wrote: Thursday 22 March 2018 19:33
Johan1974 wrote: Wednesday 21 March 2018 21:57 Hello,

I used the script:

-- 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



Every minute i have the error :

2018-03-21 21:50:00.330 Error: EventSystem: in ToonSetPoint: [string "-- Script used for Toon Thermostaat utility d..."]:8: bad argument #1 to 'pairs' (table expected, got nil

What is the problem....

You have to save this script as a Device script, not a Time script

Thank you...!!! I save it as device and that error is gone..

But I have a other error:

2018-03-22 22:57:57.860 Error: EventSystem: in ToonGetInfo: [string "-- Time script runs every minute, intended to..."]:32: attempt to index global 'jsonThermostatInfo' (a nil value)
2018-03-22 22:59:31.823 Error: EventSystem: Warning!, lua script ToonGetInfo has been running for more than 10 seconds
2018-03-22 22:59:41.998 Error: EventSystem: Warning!, lua script ToonGetInfo has been running for more than 10 seconds

At that 10 seconds, domoticz is frozen..
glsf91
Posts: 58
Joined: Tuesday 14 November 2017 21:56
Target OS: Linux
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by glsf91 »

Johan1974 wrote: Thursday 22 March 2018 23:06 But I have a other error:

2018-03-22 22:57:57.860 Error: EventSystem: in ToonGetInfo: [string "-- Time script runs every minute, intended to..."]:32: attempt to index global 'jsonThermostatInfo' (a nil value)
2018-03-22 22:59:31.823 Error: EventSystem: Warning!, lua script ToonGetInfo has been running for more than 10 seconds
2018-03-22 22:59:41.998 Error: EventSystem: Warning!, lua script ToonGetInfo has been running for more than 10 seconds

At that 10 seconds, domoticz is frozen..
Take a look if you have used the right assert line )local json = assert(loadfile....). It is depending on your OS.
Print this to the log: print(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP))) and check it and try printed url in a browser.
Check your Toon ip address and also try the curl command from you terminal (command box) directly.
Otherwise post your used script.
Johan1974
Posts: 35
Joined: Monday 04 December 2017 20:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Johan1974 »

glsf91 wrote: Friday 23 March 2018 9:24
Johan1974 wrote: Thursday 22 March 2018 23:06 But I have a other error:

2018-03-22 22:57:57.860 Error: EventSystem: in ToonGetInfo: [string "-- Time script runs every minute, intended to..."]:32: attempt to index global 'jsonThermostatInfo' (a nil value)
2018-03-22 22:59:31.823 Error: EventSystem: Warning!, lua script ToonGetInfo has been running for more than 10 seconds
2018-03-22 22:59:41.998 Error: EventSystem: Warning!, lua script ToonGetInfo has been running for more than 10 seconds

At that 10 seconds, domoticz is frozen..
Take a look if you have used the right assert line )local json = assert(loadfile....). It is depending on your OS.
Print this to the log: print(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP))) and check it and try printed url in a browser.
Check your Toon ip address and also try the curl command from you terminal (command box) directly.
Otherwise post your used script.
This is the script I used:

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
-- Udates Toon Burner status in order to see in domoticz if tyou boiler is on for the hotwater or heating or off (still is a undefined number which i must hunt down)
-- Updates Toon Boiler temp (gijsje)
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
	ToonBurnerName = uservariables['UV_ToonBurnerName']
	ToonProgramInformationSensorName = uservariables['UV_ToonProgramInformationSensorName'] -- Sensor showing displaying program information status
	ToonBoilerTempSetpoint = uservariables['UV_ToonBoilerTempSetpointSensorName'] -- Sensor showing current internal boiler temp 
    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()

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

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
	currentBurnerInfo = tonumber(jsonThermostatInfo.burnerInfo)
    currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100
	currentBoilerSetPoint = tonumber(jsonThermostatInfo.currentInternalBoilerSetpoint)
    
    -- 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.. 'C'
    else
        ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. 'C'
    end
    
    if CurrentToomProgramInformationSensorValue ~= ToonProgramInformationSensorValue then
        commandArray[6] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonProgramInformationSensorName], ToonProgramInformationSensorValue)}
    end
	
 -- Update the toon burner selector to current program state
    CurrentToonBurnerValue = otherdevices_svalues[ToonBurnerName]  
	

	if currentBurnerInfo == 0 then currentBurnerInfo = '0' -- uit
    elseif currentBurnerInfo == 1 then currentBurnerInfo = '10' -- cv aan
    elseif currentBurnerInfo == 2 then currentBurnerInfo = '20' -- warmwater aan
    end
    
    if CurrentToonBurnerValue ~= currentBurnerInfo then  -- Update toon burner selector if it has changed
        print ('Updating Toon burner info')
        commandArray[7] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonBurnerName], currentBurnerInfo)}
    end
	
--

return commandArray
glsf91
Posts: 58
Joined: Tuesday 14 November 2017 21:56
Target OS: Linux
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by glsf91 »

Johan1974 wrote: Friday 23 March 2018 10:18

Code: Select all

-- JSON data from Toon contains a extra "," which should not be there.
ThermostatInfo = string.gsub(ThermostatInfo, ",}", "}")
I don't have these 2 lines. Try without them.

Otherwise add:

Code: Select all

print(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP))) 
just before this curl line. And try the printed string in the browser.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests