Controlling Toon via Domoticz

Everything about external control, apps, VNC, etc goes here.

Moderators: marcelr, TheHogNL, Toonz

jzelle
Starting Member
Starting Member
Posts: 2
Joined: Wed Oct 16, 2019 9:32 pm

Re: Controlling Toon via Domoticz

Post by jzelle »

jzelle wrote:I have followed the manual and added the changed scripts of MadPatrick, however I am getting the following errors in my Log:

Code: Select all

2019-10-16 22:33:03.133 Error: EventSystem: in Toon: [string "return { ..."]:3: attempt to index global 'domoticz' (a nil value)
2019-10-16 22:33:03.141 Error: EventSystem: Lua script ToonSetpoint did not return a commandArray
2019-10-16 22:33:03.146 Error: EventSystem: in Toon: [string "return { ..."]:3: attempt to index global 'domoticz' (a nil value)
2019-10-16 22:33:03.152 Error: EventSystem: Lua script ToonSetpoint did not return a commandArray
Any help would be appreciated , I did update the variables to match the script.
I have used the script from Ehoco.nl and now it works :)
Ossegek
Starting Member
Starting Member
Posts: 28
Joined: Mon Dec 09, 2019 1:08 pm

Re: Controlling Toon via Domoticz

Post by Ossegek »

Hello, I got it partially started on my raspberry.
I approach this via a VNC to see what happens.
What I noticed is that domoticz goes offline when I choose 1 other scenes via scenes.
I have to restart domoticz at the prompt.

I made some screenshots, because unfortunately not everything works.
I also get no error messages. And just followed the V2 manual

Ergens heb ik vast iets gemist. Maar geen idee waar, het topic vind ik helaas ook erg rommelig.
[img]
https://ibb.co/v47Cz8x
https://ibb.co/P4DWvf1
https://ibb.co/MZj5kd9
https://ibb.co/Kj2V7Sr
[/img]
User avatar
madpatrick
Member
Member
Posts: 104
Joined: Wed Dec 06, 2017 9:52 pm
Location: Zuid-Holland

Re: Controlling Toon via Domoticz

Post by madpatrick »

Ossegek wrote:Hello, I got it partially started on my raspberry.
I approach this via a VNC to see what happens.
What I noticed is that domoticz goes offline when I choose 1 other scenes via scenes.
I have to restart domoticz at the prompt.

I made some screenshots, because unfortunately not everything works.
I also get no error messages. And just followed the V2 manual

Ergens heb ik vast iets gemist. Maar geen idee waar, het topic vind ik helaas ook erg rommelig.
[img]
https://ibb.co/v47Cz8x
https://ibb.co/P4DWvf1
https://ibb.co/MZj5kd9
https://ibb.co/Kj2V7Sr
[/img]
This script is working now.
Problem was that the script was executed as LUA and not DzVent and some UV where not correctly named.
RobbieT
Starting Member
Starting Member
Posts: 21
Joined: Sun Mar 10, 2019 3:35 pm

Re: Controlling Toon via Domoticz

Post by RobbieT »

Hi,

I'm using the script as posted by madpatrick, before that I used the script as found on ehoco.nl. All works well except 1 issue with the gas value. Every now and then the gas values are messed up. Instead of the current usage it uses the total usage. So insted of 5 m3 it used 1500m3. This confuses my reports but makes it also unable to use a cost function.

Anyone got a solution for this? I'm running the latest toon firmware.
TerrorSource
Administrator
Administrator
Posts: 494
Joined: Thu May 04, 2017 9:28 pm

Re: Controlling Toon via Domoticz

Post by TerrorSource »

RobbieT wrote:Hi,

I'm using the script as posted by madpatrick, before that I used the script as found on ehoco.nl. All works well except 1 issue with the gas value. Every now and then the gas values are messed up. Instead of the current usage it uses the total usage. So insted of 5 m3 it used 1500m3. This confuses my reports but makes it also unable to use a cost function.

Anyone got a solution for this? I'm running the latest toon firmware.
If you use the Ehoco script and you have issues, ask on that website and not here.

he steals the information from this forum without proper source linking and references.
RobbieT
Starting Member
Starting Member
Posts: 21
Joined: Sun Mar 10, 2019 3:35 pm

Re: Controlling Toon via Domoticz

Post by RobbieT »

TerrorSource wrote:
RobbieT wrote:Hi,

I'm using the script as posted by madpatrick, before that I used the script as found on ehoco.nl. All works well except 1 issue with the gas value. Every now and then the gas values are messed up. Instead of the current usage it uses the total usage. So insted of 5 m3 it used 1500m3. This confuses my reports but makes it also unable to use a cost function.

Anyone got a solution for this? I'm running the latest toon firmware.
If you use the Ehoco script and you have issues, ask on that website and not here.

he steals the information from this forum without proper source linking and references.
Read the post again, especially the first sentence....And don't get mad at me when someone is not mentioning source.
User avatar
madpatrick
Member
Member
Posts: 104
Joined: Wed Dec 06, 2017 9:52 pm
Location: Zuid-Holland

Re: Controlling Toon via Domoticz

Post by madpatrick »

RobbieT wrote:Hi,

I'm using the script as posted by madpatrick, before that I used the script as found on ehoco.nl. All works well except 1 issue with the gas value. Every now and then the gas values are messed up. Instead of the current usage it uses the total usage. So insted of 5 m3 it used 1500m3. This confuses my reports but makes it also unable to use a cost function.

Anyone got a solution for this? I'm running the latest toon firmware.
if it is the first day you are using the script, this normal.
It uses the difference between to days, but the first day is 0
RobbieT
Starting Member
Starting Member
Posts: 21
Joined: Sun Mar 10, 2019 3:35 pm

Re: Controlling Toon via Domoticz

Post by RobbieT »

Well it also happend after a couple of days. The last few days however is everything going as it should. I've made some small changes and reconnected the cables. Thanks for the awesome work!
RobbieT
Starting Member
Starting Member
Posts: 21
Joined: Sun Mar 10, 2019 3:35 pm

Re: Controlling Toon via Domoticz

Post by RobbieT »

Everything seemed to be going fine but sadly the same problem has rised again.
Image
Image
User avatar
madpatrick
Member
Member
Posts: 104
Joined: Wed Dec 06, 2017 9:52 pm
Location: Zuid-Holland

Re: Controlling Toon via Domoticz

Post by madpatrick »

RobbieT wrote:Everything seemed to be going fine but sadly the same problem has rised again.
Vreemd.
Kan je zien of je Toon wel de informatie binnen krijgt ? of dat je foutmeldingen in je domoticz log hebt
RobbieT
Starting Member
Starting Member
Posts: 21
Joined: Sun Mar 10, 2019 3:35 pm

Re: Controlling Toon via Domoticz

Post by RobbieT »

madpatrick wrote:
RobbieT wrote:Everything seemed to be going fine but sadly the same problem has rised again.
Vreemd.
Kan je zien of je Toon wel de informatie binnen krijgt ? of dat je foutmeldingen in je domoticz log hebt
In Toon komt alles goed binnen. Heb hier prima dag, week, maand overzichten. Het gekke is ook dat Domoticz het gezien het rapport wel goed weergeeft in de afgelopen 7 dagen maar dat het mis gaat bij de weken en maanden.

Uit het log:
IDX: 127 = Elektra
IDX: 206 = Gas

Code: Select all

2020-02-11 22:51:00.451  Status: dzVents: Debug: - UpdateDevice = {["sValue"]="2266750;2984514;14;0;304;0", ["idx"]=127, ["nValue"]=0}
2020-02-11 22:51:00.451  Status: dzVents: Debug: - UpdateDevice = {["sValue"]="1551061", ["idx"]=206, ["nValue"]=0}

2020-02-11 22:52:00.721  Status: dzVents: Debug: - UpdateDevice = {["nValue"]=0, ["idx"]=127, ["sValue"]="2266750;2984515;14;0;307;0"}
2020-02-11 22:52:00.721  Status: dzVents: Debug: - UpdateDevice = {["nValue"]=0, ["idx"]=206, ["sValue"]="1551061"}

2020-02-11 22:53:00.456  Status: dzVents: Debug: - UpdateDevice = {["idx"]=127, ["nValue"]=0, ["sValue"]="2266750;2984525;14;0;298;0"}
2020-02-11 22:53:00.456  Status: dzVents: Debug: - UpdateDevice = {["idx"]=206, ["nValue"]=0, ["sValue"]="0"}

2020-02-11 22:54:00.468  Status: dzVents: Debug: - UpdateDevice = {["idx"]=127, ["nValue"]=0, ["sValue"]="2266750;2984530;14;0;314;0"}
2020-02-11 22:54:00.468  Status: dzVents: Debug: - UpdateDevice = {["idx"]=206, ["nValue"]=0, ["sValue"]="0"}

2020-02-11 22:55:00.478  Status: dzVents: Debug: - UpdateDevice = {["idx"]=127, ["sValue"]="2266750;2984535;14;0;313;0", ["nValue"]=0}
2020-02-11 22:55:00.478  Status: dzVents: Debug: - UpdateDevice = {["idx"]=206, ["sValue"]="0", ["nValue"]=0}

2020-02-11 22:56:00.481  Status: dzVents: Debug: - UpdateDevice = {["nValue"]=0, ["sValue"]="2266750;2984540;14;0;304;0", ["idx"]=127}
2020-02-11 22:56:00.481  Status: dzVents: Debug: - UpdateDevice = {["nValue"]=0, ["sValue"]="1551061", ["idx"]=206}

Zie hier niet direct wat geks in behalve dat de svalue soms vooraan staan en soms achteraan.
Om 22.55 schiet mijn gaskosten ineens omhoog, vandaar dat ik die tijdstippen heb gepakt.
User avatar
madpatrick
Member
Member
Posts: 104
Joined: Wed Dec 06, 2017 9:52 pm
Location: Zuid-Holland

Re: Controlling Toon via Domoticz

Post by madpatrick »

ik weet niet met welke versie van Domoticz je draait, maar als je een Beta draait zou het hier wellicht aan kunnen liggen.
patzik
Starting Member
Starting Member
Posts: 1
Joined: Fri Mar 13, 2020 2:38 pm

Re: Controlling Toon via Domoticz

Post by patzik »

HELP!

Installatie via de handleiding volledig uitgevoerd, met copy paste om spelfouten te voorkomen. Maar nu komt domoticz niet meer online....

Als ik domoticz handmatig opstart komt er aan het einde

2020-03-13 13:16:31.846 Status: MQTT: connected to: 127.0.0.1:1883
2020-03-13 13:16:31.947 Status: MQTT: Subscribed
2020-03-13 13:16:34.696 Error: Thread 23 (Thread 0x6a3fa220 (LWP 1386)):
2020-03-13 13:16:34.696 Error: #0 __waitpid (options=0, stat_loc=0x6a3f85a0, p id=1389) at ../sysdeps/unix/sysv/linux/waitpid.c:30
2020-03-13 13:16:34.696 Error: #1 __waitpid (pid=1389, stat_loc=0x6a3f85a0, op tions=0) at ../sysdeps/unix/sysv/linux/waitpid.c:25
2020-03-13 13:16:34.696 Error: #2 0x002d8840 in dumpstack_gdb(bool) ()
2020-03-13 13:16:34.696 Error: #3 0x002d8e2c in signal_handler(int, siginfo_t* , void*) ()
2020-03-13 13:16:34.696 Error: #4 <signal handler called>
2020-03-13 13:16:34.696 Error: #5 raise (sig=6) at ../sysdeps/unix/sysv/linux/ raise.c:50
2020-03-13 13:16:34.696 Error: #6 <signal handler called>
2020-03-13 13:16:34.696 Error: #7 __GI_raise (sig=sig@entry=6) at ../sysdeps/u nix/sysv/linux/raise.c:50
2020-03-13 13:16:34.696 Error: #8 0x76b8c230 in __GI_abort () at abort.c:79
2020-03-13 13:16:34.696 Error: #9 0x00a1ad7c in __gnu_cxx::__verbose_terminate _handler() ()
2020-03-13 13:16:34.696 Error: #10 0x0097b45c in __cxxabiv1::__terminate(void ( *)()) ()
2020-03-13 13:16:34.696 Error: #11 0x0097b4d0 in std::terminate() ()
2020-03-13 13:16:34.696 Error: #12 0x00986314 in __cxa_throw ()
2020-03-13 13:16:34.696 Error: #13 0x009b5a44 in std::__throw_invalid_argument( char const*) ()
2020-03-13 13:16:34.696 Error: #14 0x0024f870 in unsigned long long __gnu_cxx:: __stoa<unsigned long long, unsigned long long, char, int>(unsigned long long (*) (char const*, char**, int), char const*, char const*, unsigned int*, int) [clone .constprop.1099] ()
2020-03-13 13:16:34.696 Error: #15 0x00268dac in CEventSystem::processLuaComman d(lua_State*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allo cator<char> > const&) ()
2020-03-13 13:16:34.696 Error: #16 0x0026a04c in CEventSystem::iterateLuaTable( lua_State*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::a llocator<char> > const&) ()
2020-03-13 13:16:34.696 Error: #17 0x0026a098 in CEventSystem::iterateLuaTable( lua_State*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::a llocator<char> > const&) ()
2020-03-13 13:16:34.696 Error: #18 0x0026a2b8 in CEventSystem::luaThread(lua_St ate*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<ch ar> > const&) ()
2020-03-13 13:16:34.696 Error: #19 0x008a3c5c in thread_proxy ()
2020-03-13 13:16:34.696 Error: #20 0x76e0b494 in start_thread (arg=0x6a3fa220) at pthread_create.c:486
2020-03-13 13:16:34.696 Error: #21 0x76c4c578 in ?? () at ../sysdeps/unix/sysv/ linux/arm/clone.S:73 from /lib/arm-linux-gnueabihf/libc.so.6
Aborted


Iemand een idee hoe ik in ieder geval domoticz weer online krijg?
User avatar
madpatrick
Member
Member
Posts: 104
Joined: Wed Dec 06, 2017 9:52 pm
Location: Zuid-Holland

Re: Controlling Toon via Domoticz

Post by madpatrick »

Hoi Patzik,

Ik kan uit de foutmeldingen niet veel opmaken en vraag me af of dit met de Toon scripts te maken heeft.
Je kunt proberen scripts te verwijderen (van je schijf) en dan weer proberen op te starten
TgF2004NL
Starting Member
Starting Member
Posts: 2
Joined: Thu Apr 15, 2021 4:29 pm

Re: Controlling Toon via Domoticz

Post by TgF2004NL »

Hi guys, been reading here a lot these days since I've rooted my Toon. I used the scripts posted in this thread. I'm still working to get all of the Toon data to Domoticz on my Synology NAS.

My progress so far:

On the 'Swithes' tab the three switches are working (jay)
On the 'Temperature' tab, ToonTemperature and ToonBoilerTempSetpoint are working (my boiler does not seems to be able to give me TempIn and TempOut, but that's fine for now. The ToonBoilerSetupoint value gives a steady 6 degrees, but why?

On the 'Utility' everything is working but the P1 meters.

I think that my main problem is getting the dev settings right.

This is the output from http://TOON IP/hdrv_zwave?action=getDevices.json

Code: Select all

{"dev_settings_device": {"uuid": "a7ffb43e-3904-41a3-8047-9ef0f717580e", "name": "settings_device", "internalAddress": "settings_device", "type": "settings_device"}, "dev_4": {"uuid": "cfc8836d-ef42-4004-ba58-75e9f9af48fb", "name": "HAE_METER_v3", "internalAddress": "4", "type": "HAE_METER_v3", "supportsCrc": "1", "ccList": "5e 86 72 32 56 5a 59 85 73 7a 60 8e 22 70 8b 3c 3d 3e", "supportedCC": "5e 86 72 32 56 5a 59 85 73 7a 60 8e 22 70 8b 3c 3d 3e", "nodeFlags": [], "IsConnected": "1", "HealthValue": "10", "DeviceName": "HAE_METER_v3", "CurrentSensorStatus": "UNKNOWN"}, "dev_4.1": {"uuid": "25850383-c67f-4e3e-a0a0-7b1b84bca8bf", "name": "HAE_METER_v3_1", "internalAddress": "4.1", "type": "HAE_METER_v3_1", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "CurrentSensorStatus": "OPERATIONAL", "CurrentGasFlow": "28.00", "CurrentGasQuantity": "4740613.00", "DeviceName": "HAE_METER_v3_1"}, "dev_4.2": {"uuid": "c28239c0-ea0e-40eb-9526-b2e700f55539", "name": "HAE_METER_v3_2", "internalAddress": "4.2", "type": "HAE_METER_v3_2", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "CurrentSensorStatus": "UNKNOWN", "DeviceName": "HAE_METER_v3_2", "CurrentElectricityFlow": "NaN", "CurrentElectricityQuantity": "NaN"}, "dev_4.3": {"uuid": "8be23555-f719-43ba-97c4-670a0815015c", "name": "HAE_METER_v3_3", "internalAddress": "4.3", "type": "HAE_METER_v3_3", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "CurrentSensorStatus": "OPERATIONAL", "DeviceName": "HAE_METER_v3_3", "CurrentElectricityFlow": "363.00", "CurrentElectricityQuantity": "586811.00"}, "dev_4.4": {"uuid": "fd387322-0004-4254-8bbe-418102e7082d", "name": "HAE_METER_v3_4", "internalAddress": "4.4", "type": "HAE_METER_v3_4", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "CurrentSensorStatus": "OPERATIONAL", "DeviceName": "HAE_METER_v3_4", "CurrentElectricityFlow": "156.00", "CurrentElectricityQuantity": "5994390.00"}, "dev_4.5": {"uuid": "64459f73-79e0-425e-80d9-66b4a9e4be1a", "name": "HAE_METER_v3_5", "internalAddress": "4.5", "type": "HAE_METER_v3_5", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "CurrentSensorStatus": "OPERATIONAL", "DeviceName": "HAE_METER_v3_5", "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "4744289.00"}, "dev_4.6": {"uuid": "41c98ea5-b61e-4b73-b00e-aa947ae10df2", "name": "HAE_METER_v3_6", "internalAddress": "4.6", "type": "HAE_METER_v3_6", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "CurrentSensorStatus": "OPERATIONAL", "DeviceName": "HAE_METER_v3_6", "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "9748242.00"}, "dev_4.7": {"uuid": "f2ddcae8-6568-4675-8963-1971d1ab3b88", "name": "HAE_METER_v3_7", "internalAddress": "4.7", "type": "HAE_METER_v3_7", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "CurrentSensorStatus": "OPERATIONAL", "DeviceName": "HAE_METER_v3_7", "CurrentElectricityFlow": "0.00", "CurrentElectricityQuantity": "1848818.00"}, "dev_4.8": {"uuid": "54066ead-7b71-4517-88d9-c7630ea5a906", "name": "HAE_METER_v3_8", "internalAddress": "4.8", "type": "HAE_METER_v3_8", "supportsCrc": "0", "ccList": "5e 59 85 8e 3c 3d 3e", "supportedCC": "5e 59 85 8e 3c 3d 3e", "nodeFlags": [], "CurrentSensorStatus": "UNKNOWN", "DeviceName": "HAE_METER_v3_8", "CurrentHeatQuantity": "NaN", "CurrentHeatFlow": "NaN"}}
These are my variables:
19 UV_P1SmartMeterGasMeterStand String P1SmartMeterGasMeterStand 2021-04-15 15:32:54
18 UV_P1SmartMeterElectra String P1SmartMeterElectra 2021-04-15 15:32:35
17 UV_ToonBoilerPressure String BoilerPressure 2021-04-15 15:32:00
16 UV_ToonBoilerTempOut String BoilerTempOut 2021-04-15 15:31:38
15 UV_ToonBoilerTempIn String BoilerTempIn 2021-04-15 15:31:14
14 UV_ToonProgramInformationSensorName String ToonProgramInfo 2021-04-15 13:20:37
13 UV_ToonAutoProgramSensorName String ToonAutoProgram 2021-04-15 13:20:04
12 UV_ToonChangedByDomoticz Integer 1 2021-04-15 13:39:41
11 UV_ToonScenesSensorName String ToonScenes 2021-04-15 13:18:56
10 UV_ToonTemperatureSensorName String ToonTemperature 2021-04-15 13:18:32
9 UV_ToonThermostatSensorName String ToonThermostat 2021-04-15 13:17:47
8 UV_ToonBurnerName String ToonBranderInfo 2021-04-15 13:17:19
7 UV_ToonBoilerTempSetpointSensorName String ToonBoilerTempSetpoint 2021-04-15 13:16:55
6 UV_ToonBoilerModulation String Boiler Modulation Level 2021-04-15 15:34:20
5 UV_ToonIP String 192.168.2.200 2021-04-12 11:13:51
3 UV_DomoticzIP String 192.168.2.153:8084 2021-04-12 11:42:37
Showing 1 to 16 of 16 entries

My Toon script:

Code: Select all

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']
    
-- Choose the correct platform which Domoticz runs on
-- Remove -- before the line which applies for your situation, set -- for all other platforms
--  json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()  -- For Raspberry
--  json = assert(loadfile "/opt/domoticz/scripts/lua/JSON.lua")()  -- For Linux (LEDE)
--  json = assert(loadfile "C:\\Program Files (x86)\\Domoticz\\scripts\\lua\\json.lua")() -- For Windows
    json = assert(loadfile "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua")() -- For Synology
    
    local handle = assert(io.popen(string.format('curl -m 5 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)
   
    if jsonThermostatInfo ~= nil then
    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)
   
        if currentSetpoint ~= nil then 
            -- 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
        end
   
        if currentTemperature ~= nil then 
            -- 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
        end
   
        if currentBoilerSetPoint ~= nil then 
			-- Update the temperature of boiler
			if otherdevices_svalues[ToonBoilerTempSetpoint]*100 ~= currentBoilerSetPoint*100 then 
				print('Updating the boiler temperature to new value: ' ..currentBoilerSetPoint)
				commandArray[3] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonBoilerTempSetpoint], currentBoilerSetPoint)}
			end
		end
		
        if currentActiveState ~= nil then 
            -- 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
        end
   
        if currentProgramState ~= nil then 
            -- 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
        end
   
        if currentNextTime ~= nil and currentNextSetPoint ~= nil then 
            -- 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
        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

    end
--
return commandArray
My ToonSetpoint script:

Code: Select all

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']
    
-- Choose the correct platform which Domoticz runs on
-- Remove -- before the line which applies for your situation, set -- for all other platforms
--  json = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()  -- For Raspberry
--  json = assert(loadfile "/opt/domoticz/scripts/lua/JSON.lua")()  -- For Linux (LEDE)
--  json = assert(loadfile "C:\\Program Files (x86)\\Domoticz\\scripts\\lua\\json.lua")() -- For Windows
    json = assert(loadfile "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua")() -- For Synology
    
    local handle = assert(io.popen(string.format('curl -m 5 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)
   
    if jsonThermostatInfo ~= nil then
    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)
   
        if currentSetpoint ~= nil then 
            -- 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
        end
   
        if currentTemperature ~= nil then 
            -- 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
        end
   
        if currentBoilerSetPoint ~= nil then 
			-- Update the temperature of boiler
			if otherdevices_svalues[ToonBoilerTempSetpoint]*100 ~= currentBoilerSetPoint*100 then 
				print('Updating the boiler temperature to new value: ' ..currentBoilerSetPoint)
				commandArray[3] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonBoilerTempSetpoint], currentBoilerSetPoint)}
			end
		end
		
        if currentActiveState ~= nil then 
            -- 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
        end
   
        if currentProgramState ~= nil then 
            -- 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
        end
   
        if currentNextTime ~= nil and currentNextSetPoint ~= nil then 
            -- 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
        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

    end
--
return commandArray
My Thermostat 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
And I created a separate data coollector script (based on what I read here):

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
The log still gives me:

Code: Select all

2021-04-15 16:48:00.513 Status: dzVents: Info: ------ Start internal script: Toon data collector:, trigger: "every minute"
2021-04-15 16:48:00.569 Status: dzVents: Info: Updating Boiler Pressure to current value: 15.0
2021-04-15 16:48:00.621 Status: dzVents: Info: ------ Finished Toon data collector
2021-04-15 16:48:00.621 Status: EventSystem: Script event triggered: /usr/local/domoticz/dzVents/runtime/dzVents.lua
2021-04-15 16:48:00.620 Error: dzVents: Error: (3.0.17) An error occurred when calling event handler Toon data collector
2021-04-15 16:48:00.620 Error: dzVents: Error: (3.0.17) ...cripts/dzVents/generated_scripts/Toon data collector.lua:64: attempt to index a nil value (field 'dev_37')
Hope you can help me here...
Post Reply

Return to “Toon external control”