Controlling Toon [HACKED] from Domoticz

For heating/cooling related questions in Domoticz

Moderator: leecollings

annesdomotic
Posts: 8
Joined: Saturday 29 December 2018 10:16
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Holland
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by annesdomotic »

EdwinK wrote: Saturday 14 December 2019 10:07 Thanks for this. Luckily, for me it's working since a few weeks.

Did you know that if you put your scripts in [c o d e] and [/ c o d e] (remove spaces) it will make it more readable, and easier to copy/paste.
i didnt know, thnxs
* raspberry pi3b+
* rooted toon 2
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 »

After a day working to Domoticz and Toon I think i'm almost done with the script to read out the Toon values.
I have 1 error left:

Code: Select all

2019-12-30 23:54:00.715 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2019-12-30 23:54:00.714 Error: dzVents: Error: (2.5.3) -=# P1 Toon #=-: An error occurred when calling event handler Toon_script
2019-12-30 23:54:00.714 Error: dzVents: Error: (2.5.3) -=# P1 Toon #=-: /home/pi/domoticz/dzVents/runtime/Utils.lua:83: attempt to perform arithmetic on a nil value (local 'x')
The room temperature is also not actual. I can set Toon, by the setpoint switch and with the scenes switch.
The temperature from the Boiler is working, in and out.

I have add the user variables as on the last page, from Patrick.

Anybody an idea?
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 »

maikelvds wrote: Monday 30 December 2019 23:59 After a day working to Domoticz and Toon I think i'm almost done with the script to read out the Toon values.
I have 1 error left:

Code: Select all

2019-12-30 23:54:00.715 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2019-12-30 23:54:00.714 Error: dzVents: Error: (2.5.3) -=# P1 Toon #=-: An error occurred when calling event handler Toon_script
2019-12-30 23:54:00.714 Error: dzVents: Error: (2.5.3) -=# P1 Toon #=-: /home/pi/domoticz/dzVents/runtime/Utils.lua:83: attempt to perform arithmetic on a nil value (local 'x')
The room temperature is also not actual. I can set Toon, by the setpoint switch and with the scenes switch.
The temperature from the Boiler is working, in and out.

I have add the user variables as on the last page, from Patrick.

Anybody an idea?
Fixed it. My boiler is quite old so he is not passing trough al info the script wants. In that case a nill value appears.
Delete the parts of the script that get a nil value and everything works.
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 »

Is it also possible to get the humidity values out of Toon2?
LeonS
Posts: 5
Joined: Thursday 24 November 2016 19:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Zwijndrecht
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by LeonS »

Hi all,

First I was trying some other scripts, UV's and devices settings from domoticaforum.eu and ehoco.nl ( they appeared first on google ;) ) Unfortunately they caused my Domoticz to crash in such a way that restoring was necessary.

So this week I tried the @madpatrick method.
using the UV's and devicenames he mentioned in the last 4 pages of this forum

The first win: Setting the Toon Thermostaat Switch results in a change on the rooted Toon, instead of crashing domoticz

Unfortunately in the Toon-script script it seems like the script doing nothing from the start, and quits somewhere in one of the first lines of the script.

Code: Select all

  
2020-01-08 22:31:00.583 Status: dzVents: Info: ------ Start internal script: Toon_script:, trigger: every minute
2020-01-08 22:31:00.714 Status: dzVents: Error (2.4.19): An error occured when calling event handler Toon_script
2020-01-08 22:31:00.714 Status: dzVents: Error (2.4.19): /home/pi/domoticz/scripts/lua/JSON.lua:660: html passed to JSON:decode(): <?xml version="1.0" encoding="iso-8859-1"?>
2020-01-08 22:31:00.714 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2020-01-08 22:31:00.714 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2020-01-08 22:31:00.714 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
2020-01-08 22:31:00.714 <head>
2020-01-08 22:31:00.714 <title>404 - Not Found</title>
2020-01-08 22:31:00.714 </head>
2020-01-08 22:31:00.714 <body>
2020-01-08 22:31:00.714 <h1>404 - Not Found</h1>
2020-01-08 22:31:00.714 </body>
2020-01-08 22:31:00.714 </html>
2020-01-08 22:31:00.714
2020-01-08 22:31:00.714 Status: dzVents: Info: ------ Finished Toon_script 
Checking the values in Domoticz Devices shows me that none of them are updated.
Can someone please advise me?

Kind regards, LeonS
OedzesG
Posts: 106
Joined: Monday 11 March 2019 0:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by OedzesG »

i have tryd manny scripts but for my it was the same.. lots of errors and not working or craching my domoticz.

So i made a verry simple script witch downloads the data from toon to update my devices in Domoticz with only 3 UserVariable
if you want i can share it?

knipsel.PNG
knipsel.PNG (222.45 KiB) Viewed 2041 times
Knipsel1.PNG
Knipsel1.PNG (70.14 KiB) Viewed 2041 times
Knipsel2.PNG
Knipsel2.PNG (109.79 KiB) Viewed 2041 times
LeonS
Posts: 5
Joined: Thursday 24 November 2016 19:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Zwijndrecht
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by LeonS »

Oooh Yes please 8-)
OedzesG
Posts: 106
Joined: Monday 11 March 2019 0:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by OedzesG »

oké, here we go...

first lets make the dummy devices, you have to create:
(hope youre Dutch! :D )

* selector switch: TOON scene
* selector switch: TOON programma
* selector switch: TOON huidige activiteit
* temperature sensor: TOON kamer temperatuur
* customsensor: TOON modulatie niveau (as-label = % )
* Thermostaat setpoint: TOON thermostaat

now we need to change te level names and level actions in the selector switches we just created.
Its important you call the level names exactly!:

* TOON scene

* level 0: Handmatige temp. instelling
* level 10: Comfort
* level 20: Thuis
* level 30: Slapen
* level 40: Weg
* level 50: Vakantie

* also activate: Verberg uit niveau!

level actions:

level 0: leave empty (its updating by the script when changing setpoint manualy!)
level 10: http://TOON_IP/happ_thermstat?action=changeSchemeState&state=2&temperatureState=0
level 20: http://TOON_IP/happ_thermstat?action=changeSchemeState&state=2&temperatureState=1
level 30: http://TOON_IP/happ_thermstat?action=changeSchemeState&state=2&temperatureState=2
level 40: http://TOON_IP/happ_thermstat?action=changeSchemeState&state=2&temperatureState=3
level 50: http://TOON_IP/happ_thermstat?action=setSetpoint&Setpoint=60

now it look like this:
TOON scene.PNG
TOON scene.PNG (50.23 KiB) Viewed 2023 times
now open the selector switch TOON programma:

level 0: Uit
level 10: Aan
level 20: Aan / afwijkend

level actions:

level 0: http://TOON_IP/happ_thermstat?action=changeSchemeState&state=0
level 10: http://TOON_IP/happ_thermstat?action=changeSchemeState&state=1
level 20: leave empty

should look like this:
TOON programma.PNG
TOON programma.PNG (25.7 KiB) Viewed 2023 times
now the final selector switch TOON huidige activiteit:
heren we only have to change the level names:

* level 0: Geen
* level 10: Verwarm. CV
* level 20: Verwarm. water
* level 30: Voor verwarm.

* also activate Verberg uit niveau
TOON activiteit.PNG
TOON activiteit.PNG (25.1 KiB) Viewed 2023 times
now you can go to youre devices menu en note the IDX numbers of the switches you just created, you need to set them in the in the script.

here comes the script:


Code: Select all


	
	local ToonIpAdres             					= '192.168.1.61'      	-- IP adres rooted TOON thermostaat 	
	local IDX_ToonActieveScene 				= 56 				-- IDX nummer van TOON scene / selector switch 					
	local IDX_ToonProgrammaVerloop			= 57 				-- IDX nummer van TOON programma / selector switch 					
	local IDX_ToonDoelTemperatuurThermostaat 	= 58 				-- IDX nummer van TOON thermostaat setpoint 					
	local IDX_ToonHuidigeKamerTemperatuur 		= 59 				-- IDX nummer van TOON kamer temperatuur 						
	local IDX_ToonHuidigeModulatieNiveau 		= 60 				-- IDX nummer van TOON modulatie niveau / custom sensor 					
	local IDX_ToonHuidigieActiviteit 			= 61 				-- IDX nummer van TOON huidige activiteit / slector switch			
				
	local   UV_ThermostaatHelper 				= 'toon_thermostaat_helper'   -- als het goed is niet veranderen 
	
	
	local scriptVersion = 'Versie 1.3'
	local scriptVar = 'TOON Thermostaat ' .. scriptVersion

	return 
		{ on = {
        httpResponses = { scriptVar },
       		 timer = {'every minute'},},
	    		logging = { level = domoticz.LOG_INFO,
       		 	marker = scriptVar },    

	execute = function(domoticz, item)
	if (item.isTimer) then
			
	domoticz.openURL({
        url = 'http://' .. ToonIpAdres .. '/happ_thermstat?action=getThermostatInfo',
        method = 'GET',
        callback = scriptVar,})
	end
			
	if (item.isHTTPResponse) then 
	domoticz.utils.dumpTable(item.headers)
           
	if item.ok then
                
	local   rawJSON = domoticz.utils.fromJSON(item.data)
	local   myData  = rawJSON
			
	local   ToonActieveScene = myData.activeState
	if 		ToonActieveScene ==  '-1' then ToonActieveSceneUpdateWaarde = 'Handmatige temp. instelling'
	elseif 	ToonActieveScene ==  '0' then ToonActieveSceneUpdateWaarde = 'Comfort'
	elseif 	ToonActieveScene ==  '1' then ToonActieveSceneUpdateWaarde = 'Thuis'
	elseif 	ToonActieveScene ==  '2' then ToonActieveSceneUpdateWaarde = 'Slapen'
	elseif 	ToonActieveScene ==  '3' then ToonActieveSceneUpdateWaarde = 'Weg'
	elseif 	ToonActieveScene ==  '4' then ToonActieveSceneUpdateWaarde = 'Vakantie'
    	end 
    	domoticz.log( '----- Toon actieve scéne = ' .. tostring(ToonActieveSceneUpdateWaarde))
	domoticz.devices(IDX_ToonActieveScene).switchSelector(ToonActieveSceneUpdateWaarde).silent()

   
	local ToonProgrammaVerloop = myData.programState
	if ToonProgrammaVerloop == '0' then ToonProgrammaVerloopUpdateWaarde = 'Uit'         
	elseif ToonProgrammaVerloop == '1' then ToonProgrammaVerloopUpdateWaarde = 'Aan'
	elseif ToonProgrammaVerloop == '2' then ToonProgrammaVerloopUpdateWaarde = 'Aan / afwijkend'
	elseif ToonProgrammaVerloop == '8' then ToonProgrammaVerloopUpdateWaarde = 'Aan / afwijkend'
    	end 
    	domoticz.log( '----- Toon automatisch programma verloop = ' .. tostring(ToonProgrammaVerloopUpdateWaarde))
	domoticz.devices(IDX_ToonProgrammaVerloop).switchSelector(ToonProgrammaVerloopUpdateWaarde).silent()
	        
	local ToonDoelTemperatuurThermostaat = myData.currentSetpoint / 100
	domoticz.log( '----- Doel temperatuur voor thermostaat: '.. tostring(ToonDoelTemperatuurThermostaat))
	domoticz.variables(UV_ThermostaatHelper).set(1)
	domoticz.devices(IDX_ToonDoelTemperatuurThermostaat).updateSetPoint(ToonDoelTemperatuurThermostaat).silent()
	        
	local ToonHuidigeKamerTemperatuur =   domoticz.utils.round((myData.currentTemp / 100),1)
    domoticz.log( '----- Huidige woonkamer temp. = ' .. tostring(ToonHuidigeKamerTemperatuur))
	domoticz.devices(IDX_ToonHuidigeKamerTemperatuur).updateTemperature(ToonHuidigeKamerTemperatuur).silent()
	        
	local ToonHuidigeModulatieNiveau  =   myData.currentModulationLevel
    domoticz.log( '----- Huidige modulatie niveau = ' .. tostring(ToonHuidigeModulatieNiveau))
	domoticz.devices(IDX_ToonHuidigeModulatieNiveau).updateCustomSensor(ToonHuidigeModulatieNiveau).silent()
	         
	local ToonHuidigieActiviteit = myData.burnerInfo
	if ToonHuidigieActiviteit == '0'  then ToonHuidigieActiviteitUpdateWaarde = 'Geen'
	elseif ToonHuidigieActiviteit == '1' then ToonHuidigieActiviteitUpdateWaarde = 'Verwarm. CV'
	elseif ToonHuidigieActiviteit == '2' then ToonHuidigieActiviteitUpdateWaarde = 'Verwarm. water'
	elseif ToonHuidigieActiviteit == '3' then ToonHuidigieActiviteitUpdateWaarde = 'Voor verwarm.'
	end 
    domoticz.log( '----- Huidige activiteit = ' .. tostring(ToonHuidigieActiviteitUpdateWaarde))
	domoticz.devices(IDX_ToonHuidigieActiviteit).switchSelector(ToonHuidigieActiviteitUpdateWaarde).silent()
	        
	                  
	           
            end     
   	    end 
    end 
}



if everything is oke, you see something like this in youre logs:

Code: Select all

2020-01-09 19:41:00.668 Status: dzVents: Info: TOON Thermostaat Versie 1.3: ----- Toon actieve scéne = Thuis
2020-01-09 19:41:00.672 Status: dzVents: Info: TOON Thermostaat Versie 1.3: ----- Toon automatisch programma verloop = Uit
2020-01-09 19:41:00.672 Status: dzVents: Info: TOON Thermostaat Versie 1.3: ----- Doel temperatuur voor thermostaat: 20.0
2020-01-09 19:41:00.672 Status: dzVents: Info: TOON Thermostaat Versie 1.3: ----- Huidige woonkamer temp. = 20.1
2020-01-09 19:41:00.673 Status: dzVents: Info: TOON Thermostaat Versie 1.3: ----- Huidige modulatie niveau = 5
2020-01-09 19:41:00.673 Status: dzVents: Info: TOON Thermostaat Versie 1.3: ----- Huidige activiteit = Geen
2020-01-09 19:41:00.673 Status: dzVents: Info: TOON Thermostaat Versie 1.3: ------ Finished Toon (Thermostaat data naar Domoticz)
OedzesG
Posts: 106
Joined: Monday 11 March 2019 0:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by OedzesG »

To update youre setpoint from Domoticz to TOON you need to use this LUA script! (NOT DzVents!)

its important you select Device at the trigger settings!

like this:
trigger.PNG
trigger.PNG (21.19 KiB) Viewed 2023 times
the script:

Code: Select all

	
	commandArray = {}

	ToonThermostatSensorName = uservariables['toon_thermostaat_naam'] -- Sensor showing current setpoint
	ToonIP = uservariables['toon_ip']

	for deviceName,deviceValue in pairs(devicechanged) do
	if (deviceName == ToonThermostatSensorName) then
	if uservariables['toon_thermostaat_helper'] == 1 then
	commandArray['Variable:toon_thermostaat_helper'] = '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
no changes or settings needed in this script!

I hope everything is working now!!
Goodluck..
User avatar
madpatrick
Posts: 659
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

LeonS wrote: Wednesday 08 January 2020 22:38 Hi all,

First I was trying some other scripts, UV's and devices settings from domoticaforum.eu and ehoco.nl ( they appeared first on google ;) ) Unfortunately they caused my Domoticz to crash in such a way that restoring was necessary.

So this week I tried the @madpatrick method.
using the UV's and devicenames he mentioned in the last 4 pages of this forum

The first win: Setting the Toon Thermostaat Switch results in a change on the rooted Toon, instead of crashing domoticz

Unfortunately in the Toon-script script it seems like the script doing nothing from the start, and quits somewhere in one of the first lines of the script.

Code: Select all

  
2020-01-08 22:31:00.583 Status: dzVents: Info: ------ Start internal script: Toon_script:, trigger: every minute
2020-01-08 22:31:00.714 Status: dzVents: Error (2.4.19): An error occured when calling event handler Toon_script
2020-01-08 22:31:00.714 Status: dzVents: Error (2.4.19): /home/pi/domoticz/scripts/lua/JSON.lua:660: html passed to JSON:decode(): <?xml version="1.0" encoding="iso-8859-1"?>
2020-01-08 22:31:00.714 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2020-01-08 22:31:00.714 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2020-01-08 22:31:00.714 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
2020-01-08 22:31:00.714 <head>
2020-01-08 22:31:00.714 <title>404 - Not Found</title>
2020-01-08 22:31:00.714 </head>
2020-01-08 22:31:00.714 <body>
2020-01-08 22:31:00.714 <h1>404 - Not Found</h1>
2020-01-08 22:31:00.714 </body>
2020-01-08 22:31:00.714 </html>
2020-01-08 22:31:00.714
2020-01-08 22:31:00.714 Status: dzVents: Info: ------ Finished Toon_script 
Checking the values in Domoticz Devices shows me that none of them are updated.
Can someone please advise me?

Kind regards, LeonS
It looks like there is an error in the scipt
An error occured when calling event handler Toon_script
If you can share more information, i can maybe check for you where it is going wrong.

What is the logfile saying ? Put the logging on debug
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.14b on Tab8" =-
LeonS
Posts: 5
Joined: Thursday 24 November 2016 19:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Zwijndrecht
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by LeonS »

OedzesG wrote: Thursday 09 January 2020 19:55 To update youre setpoint from Domoticz to TOON you need to use this LUA script! (NOT DzVents!)

----Edited----

I hope everything is working now!!
Goodluck..
Thanks for your examples, OedzesG.

Let me first try to fix things using the advice of Madpatrick. If that doesn't work, I'll restore and try using your solution.
User avatar
madpatrick
Posts: 659
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

Check-double check (triple-check) your settings, names and Uservariables.
The most problems a those related.
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.14b on Tab8" =-
LeonS
Posts: 5
Joined: Thursday 24 November 2016 19:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Zwijndrecht
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by LeonS »

It's just like a jigsaw puzzel :) I have a lot of fun tying to read the script and disabling lines:

Results till now::
  • Dev_27 (Dev_2.7) Is for power delivery from solar panels, I don't have them so I disabled every line containing it and containg formulas with it.
  • boilerstatus/boilervalues.txt doesn't exist in my Toon, So i think there's someting with my Toon configuration or My Remeha just doesn't deliver those values.
Some more values are updated now in the domoticz devices list. The only one missing except the ketel related devices is P1 elektra. Will check that one now.
OedzesG
Posts: 106
Joined: Monday 11 March 2019 0:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by OedzesG »

@LeonS

Im using also the std. TOON P1 SlimmeMeter.

Here's my script for downloading the data en updating the Domoticz Devices.
you can verry quicly test by turning the script you now using off en just set the 2 IDX numbers en TOON ip adres..


Spoiler: show

local ToonIpAdres = '192.168.1.61'
local IDX_DomoticzSlimmeMeterGas = 53
local IDX_DomoticzSlimmeMeterStroom = 54



local scriptVersion = 'Script 1.1'
local scriptVar = 'P1 SlimmeMeter ' .. scriptVersion

return
{ on = {
httpResponses = { scriptVar },
timer = {'every minute'},},
logging = { level = domoticz.LOG_ERROR,
marker = scriptVar },

execute = function(domoticz, item)

if (item.isTimer) then
domoticz.openURL({
url = 'http://'.. ToonIpAdres ..'/hdrv_zwave?action=getDevices.json',
method = 'GET',
callback = scriptVar, })
end

if (item.isHTTPResponse) then
domoticz.utils.dumpTable(item.headers)

if item.ok then
local rawJSON = domoticz.utils.fromJSON(item.data)

local mijnSlimmeMeterGas = rawJSON['dev_2.1']
local mijnSlimmeMeterElectrischHoog = rawJSON['dev_2.4']
local mijnSlimmeMeterElectrischDal = rawJSON['dev_2.6']

local mijnMeterStandGas = mijnSlimmeMeterGas.CurrentGasQuantity
local mijnHuidigeGasVerbruik = mijnSlimmeMeterGas.CurrentGasFlow

local mijnMeterStandElectrischHoog = mijnSlimmeMeterElectrischHoog.CurrentElectricityQuantity
local mijnHuidigeElectrischeVerbruikHoog = mijnSlimmeMeterElectrischHoog.CurrentElectricityFlow

local mijnMeterStandElectrischDal = mijnSlimmeMeterElectrischDal.CurrentElectricityQuantity
local mijnHuidigeElectrischeVerbruikDal = mijnSlimmeMeterElectrischDal.CurrentElectricityFlow

local mijnHuidigeElectrischeVerbruikTotaal = mijnHuidigeElectrischeVerbruikHoog + mijnHuidigeElectrischeVerbruikDal

local DataTerugLevering = '0'

local mijnMeterStandGasInM3 = mijnMeterStandGas / 1000

domoticz.devices(IDX_DomoticzSlimmeMeterGas).updateGas(mijnMeterStandGas)
domoticz.devices(IDX_DomoticzSlimmeMeterStroom).updateP1(mijnMeterStandElectrischHoog, mijnMeterStandElectrischDal,
DataTerugLevering, DataTerugLevering, mijnHuidigeElectrischeVerbruikTotaal, DataTerugLevering).silent()


domoticz.log( '********** DOMOTICZ SLIMME METER GAS EN ELECTRISCH UPDATED' )
domoticz.log( '********** NIEUWE METERSTAND GAS = '.. domoticz.utils.round(mijnMeterStandGasInM3,3).. ' m3')

if mijnHuidigeElectrischeVerbruikHoog >= '1' then
domoticz.log( '********** ELECTRISCH MOMENTEEL LEVERING TEGEN HOOG TARIEF!!' )
domoticz.log( '********** HUIDIGE VERBRUIK ELECTRISCH = ' .. domoticz.utils.round(mijnHuidigeElectrischeVerbruikTotaal,2)..' Watt' )



elseif mijnHuidigeElectrischeVerbruikDal >= '1' then
domoticz.log( '********** ELECTRISCH MOMENTEEL LEVERING TEGEN LAAG TARIEF!!' )
domoticz.log( '********** HUIDIGE VERBRUIK ELECTRISCH = ' .. domoticz.utils.round(mijnHuidigeElectrischeVerbruikTotaal,2)..' Watt' )



end
end
end
end
}
OedzesG
Posts: 106
Joined: Monday 11 March 2019 0:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by OedzesG »

sorry use it like this..

Code: Select all


local ToonIpAdres 						= '192.168.1.61'		
	local IDX_DomoticzSlimmeMeterGas    	= 53				    
    local IDX_DomoticzSlimmeMeterStroom		= 54					 
                  
        
	  
    local scriptVersion = 'Script 1.1'
	local scriptVar = 'P1 SlimmeMeter ' .. scriptVersion

	return 
	{ 	on = {
		httpResponses = { scriptVar },
		timer = {'every minute'},},
		logging = { level = domoticz.LOG_ERROR,
		marker = scriptVar },    
	
	execute = function(domoticz, item)
	
	if (item.isTimer) then
	domoticz.openURL({
		url = 'http://'.. ToonIpAdres ..'/hdrv_zwave?action=getDevices.json',
		method 	= 'GET',
		callback = scriptVar, })
		end
	
	if (item.isHTTPResponse) then
	domoticz.utils.dumpTable(item.headers)
           
	if item.ok then            
	local   rawJSON = domoticz.utils.fromJSON(item.data)
	
	local 	mijnSlimmeMeterGas 	= rawJSON['dev_2.1']  
    local   mijnSlimmeMeterElectrischHoog = rawJSON['dev_2.4'] 
	local 	mijnSlimmeMeterElectrischDal = rawJSON['dev_2.6']
	
	local 	mijnMeterStandGas = mijnSlimmeMeterGas.CurrentGasQuantity 	
	local	mijnHuidigeGasVerbruik = mijnSlimmeMeterGas.CurrentGasFlow 
	
	local 	mijnMeterStandElectrischHoog = mijnSlimmeMeterElectrischHoog.CurrentElectricityQuantity
	local 	mijnHuidigeElectrischeVerbruikHoog = mijnSlimmeMeterElectrischHoog.CurrentElectricityFlow
	
	local	mijnMeterStandElectrischDal	= mijnSlimmeMeterElectrischDal.CurrentElectricityQuantity
	local	mijnHuidigeElectrischeVerbruikDal = mijnSlimmeMeterElectrischDal.CurrentElectricityFlow
	
	local	mijnHuidigeElectrischeVerbruikTotaal = mijnHuidigeElectrischeVerbruikHoog + mijnHuidigeElectrischeVerbruikDal
	
	local	DataTerugLevering = '0'
	
	local	mijnMeterStandGasInM3 = mijnMeterStandGas / 1000
	
	domoticz.devices(IDX_DomoticzSlimmeMeterGas).updateGas(mijnMeterStandGas)
	domoticz.devices(IDX_DomoticzSlimmeMeterStroom).updateP1(mijnMeterStandElectrischHoog, mijnMeterStandElectrischDal, DataTerugLevering, DataTerugLevering, mijnHuidigeElectrischeVerbruikTotaal, DataTerugLevering).silent()
    domoticz.devices(IDX_DomoticzStatusText).updateText('Status SlimmeMeter : ' .. (mijnSlimmeMeterStatus))

    domoticz.log( '********** DOMOTICZ SLIMME METER GAS EN ELECTRISCH UPDATED' )
	domoticz.log( '********** NIEUWE METERSTAND GAS = '.. domoticz.utils.round(mijnMeterStandGasInM3,3).. '  m3') 
	
	if mijnHuidigeElectrischeVerbruikHoog >= '1' then 
	domoticz.log( '********** ELECTRISCH MOMENTEEL LEVERING TEGEN HOOG TARIEF!!' ) 
	domoticz.log( '********** HUIDIGE VERBRUIK ELECTRISCH = ' .. domoticz.utils.round(mijnHuidigeElectrischeVerbruikTotaal,2)..'  Watt' )
	
	
	
	elseif mijnHuidigeElectrischeVerbruikDal >= '1' then
	domoticz.log( '********** ELECTRISCH MOMENTEEL LEVERING TEGEN LAAG TARIEF!!' ) 
	domoticz.log( '********** HUIDIGE VERBRUIK ELECTRISCH = ' .. domoticz.utils.round(mijnHuidigeElectrischeVerbruikTotaal,2)..'  Watt' )
	
	
	       
	            end 
            end
        end
	end 
}

LeonS
Posts: 5
Joined: Thursday 24 November 2016 19:41
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Zwijndrecht
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by LeonS »

I've got a double electricity meter

http://[toon ip address]/hdrv_zwave?action=getDevices.json gives met the result below: (added some CR's for better readability)

Code: Select all

{"dev_settings_device": {"uuid": "ccef439a-3e4c-4b0c-b9eb-0dbb48bc433f", "name": "settings_device", "internalAddress": "settings_device", "type": "settings_device"}, 
"dev_2": {"uuid": "e4e84c12-1533-432e-a8db-fd24b609c10f", "name": "HAE_METER_v2", "internalAddress": "2", "type": "HAE_METER_v2", "supportsCrc": "1", 
"ccList": "22 3c 3d 3e 56 60 70 72 7a 86 8b 73", "supportedCC": "22 3c 3d 3e 56 60 70 72 7a 86 8b 73", "nodeFlags": [], "IsConnected": "1", "HealthValue": "10", 
"DeviceName": "HAE_METER_v2", "CurrentSensorStatus": "UNKNOWN"}, 

"dev_2.1": {"uuid": "c555bd27-b34a-476b-ac1f-378de4275767", "name": "HAE_METER_v2_1", "internalAddress": "2.1", "type": "HAE_METER_v2_1", "supportsCrc": "0", 
"ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "OPERATIONAL", "CurrentGasFlow": "0.00", 
"CurrentGasQuantity": "6895449.00", "DeviceName": ""}, 

"dev_2.2": {"uuid": "ed5a2742-99b1-47a5-935f-f523d5cd0e8b", "name": "HAE_METER_v2_2", "internalAddress": "2.2", "type": "HAE_METER_v2_2", "supportsCrc": "0", 
"ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "DISABLED", "DeviceName": "", "CurrentElectricityFlow": "NaN", 
"CurrentElectricityQuantity": "NaN"}, 

"dev_2.3": {"uuid": "74f9a385-aaa5-450e-8e11-317f852fc806", "name": "HAE_METER_v2_3", "internalAddress": "2.3", "type": "HAE_METER_v2_3", "supportsCrc": "0", 
"ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "OPERATIONAL", "DeviceName": "", "CurrentElectricityFlow": "674.00", 
"CurrentElectricityQuantity": "10366284.00"}, 

"dev_2.4": {"uuid": "bdda3dbe-4867-4ca0-9229-c921f8685174", "name": "HAE_METER_v2_4", "internalAddress": "2.4", "type": "HAE_METER_v2_4", "supportsCrc": "0", 
"ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "UNKNOWN", "DeviceName": "", "CurrentElectricityFlow": "0.00", 
"CurrentElectricityQuantity": "0.00"}, 

"dev_2.5": {"uuid": "29702fb4-159e-4e16-8a27-e85a0240f94b", "name": "HAE_METER_v2_5", "internalAddress": "2.5", "type": "HAE_METER_v2_5", "supportsCrc": "0", 
"ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "UNKNOWN", "DeviceName": "", "CurrentElectricityFlow": "0.00", 
"CurrentElectricityQuantity": "8881204.00"}, 

"dev_2.6": {"uuid": "50724e13-156e-42e1-bfad-5cb9317f2317", "name": "HAE_METER_v2_6", "internalAddress": "2.6", "type": "HAE_METER_v2_6", "supportsCrc": "0", 
"ccList": "3c 3d 3e 72 86", "supportedCC": "3c 3d 3e 72 86", "nodeFlags": [], "CurrentSensorStatus": "UNKNOWN", "DeviceName": "", "CurrentElectricityFlow": "0.00", 
"CurrentElectricityQuantity": "0.00"}}

I think dev_2.3 and dev_2.5 are my current electricity meter values, so I think I have to do some extra dev_xx tweaking in Madpatrick's script :)
Last edited by LeonS on Thursday 09 January 2020 23:15, edited 1 time in total.
OedzesG
Posts: 106
Joined: Monday 11 March 2019 0:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by OedzesG »

i think youre right.. 2_3 is low cost and 2_5 looks like high cost..

if youre using googe chrome you can install JSONview.

output is like this:

Code: Select all


{
dev_settings_device: {
uuid: "4deaa88d-3121-4af6-b8cc-1417058486e4",
name: "settings_device",
internalAddress: "settings_device",
type: "settings_device"
},
dev_2: {
uuid: "f59f1644-dd40-40b4-91c6-03efc85c931a",
name: "P1",
internalAddress: "2",
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: "0",
HealthValue: "1",
DeviceName: "P1",
CurrentSensorStatus: "UNKNOWN"
},
dev_2.1: {
uuid: "0a854722-adf3-4eef-8c15-5d40e7286859",
name: "HAE_METER_v3_1",
internalAddress: "2.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: "60.00",
CurrentGasQuantity: "4761692.00",
DeviceName: "HAE_METER_v3_1"
},
dev_2.2: {
uuid: "7220d93d-5fc4-4a96-a475-f43bf5ed4361",
name: "HAE_METER_v3_2",
internalAddress: "2.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_2.3: {
uuid: "00fa5693-5d13-47b4-9830-849d3048af05",
name: "HAE_METER_v3_3",
internalAddress: "2.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: "UNKNOWN",
DeviceName: "HAE_METER_v3_3",
CurrentElectricityFlow: "NaN",
CurrentElectricityQuantity: "NaN"
},
dev_2.4: {
uuid: "f5cedc5f-465b-42fe-9bd2-3428a3543fc3",
name: "HAE_METER_v3_4",
internalAddress: "2.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: "455.00",
CurrentElectricityQuantity: "1456849.00"
},
dev_2.5: {
uuid: "bb418508-33cd-4e52-ab01-ce4c3783873c",
name: "HAE_METER_v3_5",
internalAddress: "2.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: "0.00"
},
dev_2.6: {
uuid: "14b74689-8cce-43fd-9cef-58cc176abaf6",
name: "HAE_METER_v3_6",
internalAddress: "2.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: "1118510.00"
},
dev_2.7: {
uuid: "f35da869-8344-45c0-9f1a-e60c3907c2fd",
name: "HAE_METER_v3_7",
internalAddress: "2.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: "0.00"
},
dev_2.8: {
uuid: "f5bddf0e-1c0d-41f6-8dfc-0e89bfcc72d4",
name: "HAE_METER_v3_8",
internalAddress: "2.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"
}
}

User avatar
George
Posts: 8
Joined: Saturday 16 June 2018 16:33
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by George »

After trying the Dzvent script as explained in: https://ehoco.nl/geroote-toon-bedienen-met-domoticz/, Domoticz is verry slow and/or hangs.

So I tried the scripts from OedzesG.

Don't know what I did wrong but I get no Values.

Here what I did:
Created dummy devices
Changed the level names and level actions in the selector switches (called the level names exactly)
t1.JPG
t1.JPG (75.4 KiB) Viewed 1946 times
t2.JPG
t2.JPG (51.74 KiB) Viewed 1946 times
t3.JPG
t3.JPG (41.13 KiB) Viewed 1946 times
So far so Good :D
Using: Domoticz V4.10717, Raspberry 3B+, Z-wave plus, Wemos
User avatar
George
Posts: 8
Joined: Saturday 16 June 2018 16:33
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by George »

Search for Idx:
t5.JPG
t5.JPG (43.04 KiB) Viewed 1944 times
Then created Lua script (Copy past, just edit IP adres Toon and IDX)
t4.JPG
t4.JPG (98.8 KiB) Viewed 1944 times
also use this LUA script To update setpoint from Domoticz to TOON:
t6.JPG
t6.JPG (59.64 KiB) Viewed 1944 times
But finally I can not read/change values.... at least there is no change in domoticz.

What went wrong?
Is the first scrip LUA? (what I did) or is it dzVents?
Using: Domoticz V4.10717, Raspberry 3B+, Z-wave plus, Wemos
User avatar
George
Posts: 8
Joined: Saturday 16 June 2018 16:33
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10717
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by George »

Update:
Created first script (Toon Script) as dzVents.
And las one - as mentioned - as LUA and set trigger as device.

Log file:
toonlog1.JPG
toonlog1.JPG (75.78 KiB) Viewed 2306 times
This works:
werkt1.JPG
werkt1.JPG (37.26 KiB) Viewed 2306 times
And this not:
werktniet1en2.jpg
werktniet1en2.jpg (70.12 KiB) Viewed 2306 times
No reaction when i change set point for temp.
No temp. reading.

:roll: Take some Beer for now.... maybe that helps :lol:
Using: Domoticz V4.10717, Raspberry 3B+, Z-wave plus, Wemos
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest