Controlling Toon via Domoticz

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

Moderators: marcelr, TheHogNL, TerrorSource, Toonz

Re: Controlling Toon via Domoticz

Postby Jobsoft » Thu Jul 18, 2019 9:16 pm

TerrorSource wrote:Hi guys,

As requested by a few users around here i've created a how-to manual to control Toon via Domoticz.
It's pretty much a step-by-step guide and should be enough to get it working within 20-30minutes.

The complete manual is based off information and scripts found on: https://www.domoticz.com/forum/viewtopic.php?t=11421

Please ask for support in the topic/url mention above. The scripts are made by users on that forum, not by me.
I will not take credit for the scripts.
I will however create a new version of the manual when there are errors or improvements possible in the current manual.

I wil not support this manual or the content of it!

There's are seperate manuals for Dutch and English.

Please do NOT distribute this document or the content in any kind. It is for personal use only.

Version 2 available now:
- Fixes typo's
- Added LUA/DzVents option enabling

Dutch: Download v2
English: Download v2


If I set it up my Domoticz crashes. If I disable the Toon script it doesn't crash. I did exactly what was in the manual and checked it for typo's 5 times. I have no clue how to fix this.
Can someone point me in the right direction please?

Thanks!
Jobsoft
Starting Member
Starting Member
 
Posts: 1
Joined: July 2019

Re: Controlling Toon via Domoticz

Postby witteherder » Thu Jul 25, 2019 4:17 pm

At step 7 I have put by Eventsystem everything on ON

Then I went to Setup More options then to Eventst to add scipts.
Then I see this like in my attachement.
1. Where can i put/add extra script Toon_script.txt
2. I also see in this topic that its not working by everybody who has a Toon2: What do i have to change in this 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
Attachments
Stap7ToonScript.jpg
Stap 7 Handleiding Toon Script toevoegen
Stap7ToonScript.jpg (83.72 KiB) Viewed 1522 times
Last edited by witteherder on Thu Jul 25, 2019 5:13 pm, edited 1 time in total.
Toon 2 Rooted User
Firmware version: 5.9.6
Raspberry Pi 3B+
Domoticz V4.10717
7 Neo Coolcam PowerPlus
Domotica Beginner (need little help in beginning)
witteherder
Starting Member
Starting Member
 
Posts: 22
Joined: January 2019

Re: Controlling Toon via Domoticz

Postby TerrorSource » Fri Jul 26, 2019 9:49 am

MarcF wrote:To All,

Based on the manual from TerrorSource domoticaforum.eu/viewtopic.php?f=102&am ... mp;t=12097 and BOverdevest domoticaforum.eu/viewtopic.php?f=102&am ... p;start=15 I created 2 files.

// STARTING
Download the manual from TerrorSource, base topic page 1. This Manual explains how you create virtual sensors and define User Variables
The Virtual sensors (Devices) and User Variables you create need to have the EXACT value that is used within the scripts. If this doesn't match, the scripts won't work

To help you out, here is some helpfull data for setting up the Toon <=> Domoticz connection with the proces described by TerrorSource and the script from BOverdevest

NOTE: Download notepad++ if you don;y have it allready. It's free and very usefull! You can use it to replace some parts in the files (personal config settings)

When all is set up, you can use this script. Please also note the remarks in the top part to update some parts of the script to make it match your situation


When all is done correctly, it will work with a rooted Toon, fw 5.04. Maybe you need to install the boilerstatus module from the toonstore if you get boiler issues.



I'm getting the following errors:

2019-07-26 10:37:00.612 Error: dzVents: Error: (2.4.26) An error occurred when calling event handler Toon
2019-07-26 10:37:00.613 Error: dzVents: Error: (2.4.26) /home/pi/domoticz/dzVents/runtime/Utils.lua:45: attempt to perform arithmetic on local 'x' (a nil value)
TerrorSource
Member
Member
 
Posts: 281
Joined: May 2017

Re: Controlling Toon via Domoticz

Postby brommetje » Wed Jul 31, 2019 10:54 am

Hi @MarcF thanks for your clear explanation, just implemented the script, devices etc. and it looks like it is working but if I have a look to the BoilerPressure is for example 18.9 BAR so I changed the script.
Re: Controlling Toon via Domoticz
New postby MarcF » Fri Mar 08, 2019 8:27 pm

To All,

Based on the manual from TerrorSource domoticaforum.eu/viewtopic.php?f=102&am ... mp;t=12097 and BOverdevest domoticaforum.eu/viewtopic.php?f=102&am ... p;start=15 I created 2 files.

// STARTING

Code: Select all
-- Update the Boiler water Pressure to current value
        local currentBoilerPressure = tonumber(jsonBoilerInfo.boilerPressure) * 10
        ...
Code: Select all
-- Update the Boiler water Pressure to current value
        -- local currentBoilerPressure = tonumber(jsonBoilerInfo.boilerPressure) * 10
        local currentBoilerPressure = tonumber(jsonBoilerInfo.boilerPressure)

and now my BoilerPressure = 1.9 BAR and that looks OK so my question why did you do the calculation * 10 ?

Or is there already a new updated one or missing something?

Regards,
Martin
brommetje
Starting Member
Starting Member
 
Posts: 7
Joined: October 2018

Re: Controlling Toon via Domoticz

Postby witteherder » Sat Aug 17, 2019 3:18 pm

Where can I check this error from the Domoticz log file?

2019-08-17 16:01:34.568 Status: PROXY: Authenticate result: success.
2019-08-17 16:06:17.024 (Dummy) Thermostat (ToonThermostat)
2019-08-17 16:06:17.025 Status: EventSystem: reset all device statuses...
2019-08-17 16:06:17.173 Status: LUA: Updating the temperature sensor to new value: 24.11
2019-08-17 16:06:17.174 Status: EventSystem: Script event triggered: Toon
2019-08-17 16:06:17.176 Status: LUA: Setting Toon setpoint to 10.00
2019-08-17 16:06:17.176 Status: EventSystem: Fetching URL http://192.168.2.15/happ_thermstat?acti ... point=1000 after 0.2 seconds...
2019-08-17 16:06:17.176 Status: EventSystem: Script event triggered: ToonThermostat
2019-08-17 16:06:17.173 Error: EventSystem: in Toon: [string "commandArray = {}..."]:58: attempt to perform arithmetic on field '?' (a nil value)
2019-08-17 16:06:22.737 Status: EventSystem: reset all device statuses...
2019-08-17 16:06:25.093 Status: EventSystem: reset all device statuses...
2019-08-17 16:06:55.630 Status: EventSystem: reset all device statuses...
Toon 2 Rooted User
Firmware version: 5.9.6
Raspberry Pi 3B+
Domoticz V4.10717
7 Neo Coolcam PowerPlus
Domotica Beginner (need little help in beginning)
witteherder
Starting Member
Starting Member
 
Posts: 22
Joined: January 2019

Re: Controlling Toon via Domoticz

Postby phoenixb » Sun Aug 25, 2019 1:40 pm

Duiken60 wrote:Have my Toon working on Domoticz but only after turning the option "local access" on but that works only for 2 hrs. How can I get is working without time limitation?
Same issue here, do you have already find an solution for this problem?
__________________
phoenixb
Member
Member
 
Posts: 496
Joined: July 2009
Location: Netherlands

Re: Controlling Toon via Domoticz

Postby TerrorSource » Mon Aug 26, 2019 1:04 pm

phoenixb wrote:
Duiken60 wrote:Have my Toon working on Domoticz but only after turning the option "local access" on but that works only for 2 hrs. How can I get is working without time limitation?
Same issue here, do you have already find an solution for this problem?


Can you try an "update-rooted.sh -f" to re-do the fixes? Please post the result
TerrorSource
Member
Member
 
Posts: 281
Joined: May 2017

Re: Controlling Toon via Domoticz

Postby mAiden » Mon Aug 26, 2019 1:57 pm

phoenixb wrote:
Duiken60 wrote:Have my Toon working on Domoticz but only after turning the option "local access" on but that works only for 2 hrs. How can I get is working without time limitation?
Same issue here, do you have already find an solution for this problem?


Try to fix youre iptables. Maybe the port to HTTP is be closed.
10080 must be uncomment! :)
mAiden
Member
Member
 
Posts: 239
Joined: July 2017

Re: Controlling Toon via Domoticz

Postby phoenixb » Mon Aug 26, 2019 2:56 pm

TerrorSource wrote:
phoenixb wrote:
Duiken60 wrote:Have my Toon working on Domoticz but only after turning the option "local access" on but that works only for 2 hrs. How can I get is working without time limitation?
Same issue here, do you have already find an solution for this problem?


Can you try an "update-rooted.sh -f" to re-do the fixes? Please post the result
That solved the problem. Thx.
__________________
phoenixb
Member
Member
 
Posts: 496
Joined: July 2009
Location: Netherlands

Re: Controlling Toon via Domoticz

Postby Xavier » Wed Sep 04, 2019 6:55 pm

Hi,

I used the script in the post of "MarcF » Fri Mar 08, 2019 7:27 pm "
Now I get this error:
" Status: dzVents: Error (2.4.19): An error occured when calling event handler Toon
2019-09-04 19:43:00.530 Status: dzVents: Error (2.4.19): /volume1/@appstore/domoticz/var/scripts/lua/JSON.lua:194: HTML passed to JSON:decode(): <?xml version="1.0" encoding="iso-8859-1"?>
2019-09-04 19:43:00.530 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2019-09-04 19:43:00.530 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2019-09-04 19:43:00.530 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
2019-09-04 19:43:00.530 <head>
2019-09-04 19:43:00.530 <title>404 - Not Found</title>
2019-09-04 19:43:00.530 </head>
2019-09-04 19:43:00.530 <body>
2019-09-04 19:43:00.530 <h1>404 - Not Found</h1>
2019-09-04 19:43:00.530 </body>
2019-09-04 19:43:00.530 </html> "

I'm using Domoticz on mij Synology with version 4.10717.
Folder and file permissions should be ok.
This messages keeps returning.
How can I fix this?
Toon1 with 5.9.6 firmware TSC 2.0
Apps: Calender, garbagecalender, traffic information, webcam, doorcam, public transport and weather app.
Xavier
Member
Member
 
Posts: 60
Joined: January 2019

Re: Controlling Toon via Domoticz

Postby madpatrick » Wed Sep 04, 2019 7:07 pm

Can you check the if the location "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua" is correct on your server
User avatar
madpatrick
Member
Member
 
Posts: 85
Joined: December 2017
Location: Zuid-Holland

Re: Controlling Toon via Domoticz

Postby witteherder » Wed Sep 04, 2019 7:14 pm

mAiden wrote:For the people with smart plugs, here a detailed explanation, how to connect them to Domoticz.
This way you can also switch your plugs on time, and you are totally independent of Olisto or a Service Center. ;-)

English version comes as soon as possible .. Here the Dutch version ..

Slimme stekkers Toon in Domoticz.pdf

How you can see the power consumption in Domoticz from the smart plugs used in Toon
Toon 2 Rooted User
Firmware version: 5.9.6
Raspberry Pi 3B+
Domoticz V4.10717
7 Neo Coolcam PowerPlus
Domotica Beginner (need little help in beginning)
witteherder
Starting Member
Starting Member
 
Posts: 22
Joined: January 2019

Re: Controlling Toon via Domoticz

Postby Xavier » Wed Sep 04, 2019 7:50 pm

madpatrick wrote:Can you check the if the location "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua" is correct on your server


I did several times.
also changed to /usr/local/domoticz/var/scripts/lua/JSON.lua

When using this link I get an error that domoticz had no right to view this folder.
Last edited by Xavier on Wed Sep 04, 2019 7:55 pm, edited 1 time in total.
Toon1 with 5.9.6 firmware TSC 2.0
Apps: Calender, garbagecalender, traffic information, webcam, doorcam, public transport and weather app.
Xavier
Member
Member
 
Posts: 60
Joined: January 2019

Re: Controlling Toon via Domoticz

Postby madpatrick » Wed Sep 04, 2019 7:53 pm

Xavier wrote:
madpatrick wrote:Can you check the if the location "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua" is correct on your server


I die several homes.
also changed to /usr/local/domoticz/var/scripts/lua/JSON.lua

When using this link I get an error that domoticz had no right to view this folder.


Did you check where the file json.lua is located on your server ?
If this is a different location, change this in the script
User avatar
madpatrick
Member
Member
 
Posts: 85
Joined: December 2017
Location: Zuid-Holland

Re: Controlling Toon via Domoticz

Postby Xavier » Wed Sep 04, 2019 7:56 pm

madpatrick wrote:
Xavier wrote:
madpatrick wrote:Can you check the if the location "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua" is correct on your server


I die several homes.
also changed to /usr/local/domoticz/var/scripts/lua/JSON.lua

When using this link I get an error that domoticz had no right to view this folder.


Did you check where the file json.lua is located on your server ?
If this is a different location, change this in the script


This the location where JSON.lua for domoticz is located
Toon1 with 5.9.6 firmware TSC 2.0
Apps: Calender, garbagecalender, traffic information, webcam, doorcam, public transport and weather app.
Xavier
Member
Member
 
Posts: 60
Joined: January 2019

PreviousNext

Return to Toon external control

Who is online

Users browsing this forum: No registered users and 1 guest