Toon as a domotica controller?

Everything about rooting Toons 1 and 2.

Moderators: marcelr, TheHogNL, Toonz

marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Toon as a domotica controller?

Post by marcelr »

The toonstore installer applies the 403-forbidden patch as part of the installation.
It can also be done manually:
viewtopic.php?f=87&t=11235#p82535
TheHogNL
Forum Moderator
Forum Moderator
Posts: 2125
Joined: Sun Aug 20, 2017 8:53 pm

Re: Toon as a domotica controller?

Post by TheHogNL »

TheHogNL wrote:Found another URL which should be helpfull.. however I didn't manage to find the correct parameters yet.
The URL is /happ_thermstat?action=updateDhwValue

And should be appened with some unknown parameters. I tried &enabled=0 or &setpoint=40 already and some others. But no luck yet. The result is always OK but no messages been sent towards the boiler.
Found how to change the dhw boiler preheat setup. Could not find a http url yet, but from the console this is the command:

Code: Select all

/qmf/bin/bxt -d :happ_thermstat -s Thermostat -n SetDhwSettings -a dhwEnabled -v 0 -w 0
The following options are also available:

Code: Select all

/qmf/bin/bxt -d :happ_thermstat -s Thermostat -n SetDhwSettings -a dhwSetpoint -v 50 -w 0
/qmf/bin/bxt -d :happ_thermstat -s Thermostat -n SetDhwSettings -a dhwEnabled -v 0 -a dhwSetpoint -v 50 -w 0
So you now only need something to run this remote. Can't be hard to do.
Member of the Toon Software Collective
Hypermobile
Member
Member
Posts: 76
Joined: Sun Jan 14, 2018 5:12 pm

Re: Toon as a domotica controller?

Post by Hypermobile »

TheHogNL wrote:
TheHogNL wrote:Found another URL which should be helpfull.. however I didn't manage to find the correct parameters yet.
The URL is /happ_thermstat?action=updateDhwValue

And should be appened with some unknown parameters. I tried &enabled=0 or &setpoint=40 already and some others. But no luck yet. The result is always OK but no messages been sent towards the boiler.
Found how to change the dhw boiler preheat setup. Could not find a http url yet, but from the console this is the command:

Code: Select all

/qmf/bin/bxt -d :happ_thermstat -s Thermostat -n SetDhwSettings -a dhwEnabled -v 0 -w 0
The following options are also available:

Code: Select all

/qmf/bin/bxt -d :happ_thermstat -s Thermostat -n SetDhwSettings -a dhwSetpoint -v 50 -w 0
/qmf/bin/bxt -d :happ_thermstat -s Thermostat -n SetDhwSettings -a dhwEnabled -v 0 -a dhwSetpoint -v 50 -w 0
So you now only need something to run this remote. Can't be hard to do.
Great Stuff again. Maybe somebody else now knows how to fix the URL for this :)

maybe we can reverse engineer a Know URL like this one http://192.168.0.15/happ_thermstat?acti ... te&state=0

to get a clue how it's done
michel30
Member
Member
Posts: 286
Joined: Fri Aug 25, 2017 4:42 pm

Re: Toon as a domotica controller?

Post by michel30 »

Hello,

Do you know what this is: http://192.168.0.15/hdrv_zwave/ I see an orange balk with control but you can not click on it.
Ierlandfan
Member
Member
Posts: 151
Joined: Thu Oct 03, 2013 7:53 pm

Re: Toon as a domotica controller?

Post by Ierlandfan »

Code: Select all

grep -r "?action=" /qmf/www/
(Not optimized)

This way you can try/find a lot of predefined "action" commands.
atlantica
Starting Member
Starting Member
Posts: 34
Joined: Fri Mar 02, 2018 10:46 am

Re: Toon as a domotica controller?

Post by atlantica »

Eggybert wrote:Cleaned the P1 script a little and added some more comments, it still works the same:

Code: Select all

return {
    
    -- 'active' controls if this entire script is considered or not
	active = true, -- set to false to disable this script
	logging = {
		level = domoticz.LOG_INFO, -- Select one of LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE to override system log level
		marker = "P1 toon"
	},
	on = {
		timer = {
			'every minute'
		}
	},
	execute = function(domoticz)
	    
        --Replace all dev_2 for your number you can find @ http://192.168.178.29/hdrv_zwave?action=getDevices
        --Replace IDX number GasIDX and ElectricityIDX
        --make the User Valriables ToonIP is a string: 192.168.1.1
        --make sure Dzvents is active under settings/other
        
        local ToonIP = domoticz.variables('UV_ToonIP').value
        local GasIDX = 17
        local ElectricityIDX = 16

        --Handle json, select your system
        --local json = assert(loadfile "C:\\Program Files (x86)\\Domoticz\\scripts\\lua\\json.lua")()  -- For Windows
        --local json = assert(loadfile "/home/maes/domoticz/scripts/lua/JSON.lua")()  -- For Linux
        local json = assert(loadfile "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua")()  -- For Synology
            json.strictTypes = true

        --Ask toon for the latest data            
        local handle2 = assert(io.popen(string.format('curl http://%s/hdrv_zwave?action=getDevices.json', ToonIP)))
        local ZwaveInfo = handle2:read('*all')
        handle2:close()

        --Found this by luck, no idea why it works :P but it removes the . between the numbers
        ZwaveInfo = string.gsub(ZwaveInfo, "dev_2.", "dev_2")
        ZwaveInfo = string.gsub(ZwaveInfo, "dev_2:", "dev_2\":")
        
        --decode the json string to lua table
        local jsonZwaveInfo = json:decode(ZwaveInfo)
        
        --if the table is empty something went wrong
        if jsonZwaveInfo == nil then
            domoticz.log('<font color="green">No data from toon', domoticz.LOG_INFO)
            return
        end
        
        --the following data is interesting for us 
        --dev_2.1:CurrentGasQuantity
        --Elec high
        --dev_2.3:CurrentElectricityFlow
        --dev_2.3:CurrentElectricityQuantity
        --Elec low
        --dev_2.5:CurrentElectricityQuantity
        --dev_2.5:CurrentElectricityFlow
        
        --Elec produced high
        --dev_2.4:CurrentElectricityQuantity
        --dev_2.4:CurrentElectricityFlow
        
         --Elec produced low
        --dev_2.6:CurrentElectricityQuantity
        --dev_2.6:CurrentElectricityFlow
        
        
        local CurrentGasQuantity = tonumber(jsonZwaveInfo["dev_21"]["CurrentGasQuantity"])
        --print(CurrentGasQuantity .. " CurrentGasQuantity")
        
        local CurrentElectricityQuantityHoog = tonumber(jsonZwaveInfo["dev_23"]["CurrentElectricityQuantity"])
        --print(CurrentElectricityQuantityHoog .. "kWh CurrentElectricityQuantityHoog")
        local CurrentElectricityFlowHoog = tonumber(jsonZwaveInfo["dev_23"]["CurrentElectricityFlow"])
        --print(CurrentElectricityFlowHoog .. "W CurrentElectricityFlowHoog")
        
        local CurrentElectricityQuantityLaag = tonumber(jsonZwaveInfo["dev_25"]["CurrentElectricityQuantity"])
        --print(CurrentElectricityQuantityLaag .. "kWh CurrentElectricityQuantityLaag")
        local CurrentElectricityFlowLaag = tonumber(jsonZwaveInfo["dev_25"]["CurrentElectricityFlow"])
        --print(CurrentElectricityFlowLaag .. "W CurrentElectricityFlowLaag")   

        --not interested when the current power is made
        local totalPower = CurrentElectricityFlowHoog + CurrentElectricityFlowLaag
        --print(totalPower .. "W totalPower") 

        local CurrentElectricityDeliveredLaag = tonumber(jsonZwaveInfo["dev_24"]["CurrentElectricityQuantity"])
        --print(CurrentElectricityDeliveredLaag .. "kWh CurrentElectricityDeliveredLaag")
        local CurrentElectricityDeliveredFlowLaag = tonumber(jsonZwaveInfo["dev_24"]["CurrentElectricityFlow"])
        --print(CurrentElectricityDeliveredFlowLaag .. "W CurrentElectricityFlowLaag")  
        
        local CurrentElectricityDeliveredHoog = tonumber(jsonZwaveInfo["dev_26"]["CurrentElectricityQuantity"])
        --print(CurrentElectricityDeliveredHoog .. "kWh CurrentElectricityDeliveredLaag")
        local CurrentElectricityDeliveredFlowHoog = tonumber(jsonZwaveInfo["dev_26"]["CurrentElectricityFlow"])
        --print(CurrentElectricityDeliveredFlowHoog .. "W CurrentElectricityFlowLaag")  

        local totalDeliveredPower = CurrentElectricityDeliveredFlowHoog + CurrentElectricityDeliveredFlowLaag
        --print(totalDeliveredPower .. "W totalPower") 
        
        --USAGE1= energy usage meter tariff 1
        --USAGE2= energy usage meter tariff 2
        --RETURN1= energy return meter tariff 1
        --RETURN2= energy return meter tariff 2
        --CONS= actual usage power (Watt)
        --PROD= actual return power (Watt)
        
        --updateP1(usage1, usage2, return1, return2, cons, prod): Function. Updates the device. Supports command options.     
        domoticz.log('<font color="green">P1 from toon: ' .. CurrentElectricityQuantityLaag/1000 .. 'kwh USAGE1 | ' ..CurrentElectricityQuantityHoog/1000 .. 'kwh USAGE2 | ' .. CurrentElectricityDeliveredLaag/1000 .. 'kwh RETURN1 | ' .. CurrentElectricityDeliveredHoog/1000 .. 'kwh RETURN2 | ' .. totalPower .. 'w consumed | '.. totalDeliveredPower .. 'w produced', domoticz.LOG_INFO)
        domoticz.devices(ElectricityIDX).updateP1(CurrentElectricityQuantityLaag, CurrentElectricityQuantityHoog, CurrentElectricityDeliveredLaag, CurrentElectricityDeliveredHoog, totalPower, totalDeliveredPower)
        
        --update gas
        domoticz.log('<font color="green">Gas from toon: ' .. CurrentGasQuantity/1000 .. 'm3', domoticz.LOG_INFO)
        domoticz.devices(GasIDX).updateGas(CurrentGasQuantity)

	end
}
And here is the code for non smart meters for toon, thanks Hypermobile for testing for me (sorry for the counter resets :lol:)
*15-02-2018 fixed a bug in the code
*16*02*2018 fixed gas bug but the electricity is still wrong

Code: Select all

return {
    
    -- 'active' controls if this entire script is considered or not
	active = true, -- set to false to disable this script
	logging = {
		level = domoticz.LOG_INFO, -- Select one of LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE to override system log level
		marker = "Power toon"
	},
	on = {
		timer = {
			'every minute'
		}
	},
	data = {
	    lastKwhMemory = { history = true, maxItems = 1 },
        lastGasMemory = { history = true, maxItems = 1 },
        BackupGas = { history = true, maxItems = 1 }
	},
	execute = function(domoticz)
        --Replace all dev_3 for your number you can find @ http://***.***.***.***/hdrv_zwave?action=getDevices
        --Replace IDX number to your IDX numers. Gas and electic instance/counter
        --make the User Valriables ToonIP is a string: 192.168.1.1
        --make sure Dzvents is active under settings/other
        --first time this script starts it will take 3 cycles(3min) to fill all the values
        
        local ToonIP = domoticz.variables('UV_ToonIP').value
        local GasIDX = 371
        local ElectricityIDX = 372

        --Handle json, select your system
        --local json = assert(loadfile "C:\\Program Files (x86)\\Domoticz\\scripts\\lua\\json.lua")()  -- For Windows
        --local json = assert(loadfile "/home/maes/domoticz/scripts/lua/JSON.lua")()  -- For Linux
        local json = assert(loadfile "/volume1/@appstore/domoticz/var/scripts/lua/JSON.lua")()  -- For Synology
            json.strictTypes = true
        
        --Ask toon for the latest data    
        local handle = assert(io.popen(string.format('curl http://%s/hdrv_zwave?action=getDevices.json', ToonIP)))
        local ZwaveInfo = handle:read('*all')
        handle:close()

        --Found this by luck, no idea why it works :P but it removes the . between the numbers
        ZwaveInfo = string.gsub(ZwaveInfo, "dev_3.", "dev_3")
        ZwaveInfo = string.gsub(ZwaveInfo, "dev_3:", "dev_3\":")

        --decode the json string to a lua table
        local jsonZwaveInfo = json:decode(ZwaveInfo)
        
        --if the lua table is emty stop the script
        if jsonZwaveInfo == nil then
            domoticz.log('<font color="green">No data from Toon', domoticz.LOG_INFO)
            return
        end
        
        --first time this script runs the lastMemory values need to be filled
        if(domoticz.data.lastKwhMemory.size == 0 or domoticz.data.lastGasMemory.size == 0) then
            domoticz.log('<font color="green">Last memory empty', domoticz.LOG_INFO)
            domoticz.data.lastKwhMemory.add(0)
            domoticz.data.lastGasMemory.add(0)
            return
        end
        
        --On the first write of the day to the gas counter the counter will show 0 (bug in domoticz) use the backup vlaue instead
        if(domoticz.data.BackupGas.size == 0) then
           domoticz.data.BackupGas.add(0)
        end
        
        --the following data is interesting for us 
        --dev_2.1:CurrentGasQuantity
        --Elec
        --dev_2.2:CurrentElectricityQuantity
        --dev_2.2:CurrentElectricityFlow

        
        local CurrentGasQuantity = tonumber(jsonZwaveInfo["dev_31"]["CurrentGasQuantity"])
        --print(CurrentGasQuantity .. " CurrentGasQuantity")
        local CurrentElectricityQuantity = tonumber(jsonZwaveInfo["dev_32"]["CurrentElectricityQuantity"])
        --print(CurrentElectricityQuantity .. "kWh CurrentElectricityQuantity")
        local CurrentElectricityFlow = tonumber(jsonZwaveInfo["dev_32"]["CurrentElectricityFlow"])
        --print(CurrentElectricityFlow .. "W CurrentElectricityFlow")
        
        local TempElectricity = 0

        --if the value from toon is higher then the memory from last loop and the memory from last loop is not 0
        if(CurrentElectricityQuantity >= domoticz.data.lastKwhMemory.getLatest().data and domoticz.data.lastKwhMemory.getLatest().data ~= 0) then
        
            --Calcukate new value 201 = 200(user variable) + (101(new value) - 100(memory last loop))
            --TempElectricity = KwhMemory + (CurrentElectricityQuantity - domoticz.data.lastKwhMemory.getLatest().data)
            TempElectricity = domoticz.devices(ElectricityIDX).WhTotal + (CurrentElectricityQuantity - domoticz.data.lastKwhMemory.getLatest().data)
            
            --Electric usage
            --WhActual: Number. Current Watt usage.
            --updateEnergy(energy): Function. In Watt. Supports command options.
            domoticz.log('<font color="green">Power from toon: ' .. TempElectricity/1000 .. 'kwh USAGE | ' .. CurrentElectricityFlow .. 'w consumed | ', domoticz.LOG_INFO)
            domoticz.devices(ElectricityIDX).updateElectricity(CurrentElectricityFlow,TempElectricity)

            --save data for next loop
            domoticz.data.lastKwhMemory.add(CurrentElectricityQuantity)
        
        else 
            --lastKwhMemory is emtpy so no idea how much usage there was. set for next loop. Or for some reason the memory had a higher value.
            domoticz.data.lastKwhMemory.add(CurrentElectricityQuantity)
        end

        --Gas
        local TempGas = 0
        
        --check if the counter is higher then lastGasMemory and the lastGasMemory is not 0
        if(CurrentGasQuantity >= domoticz.data.lastGasMemory.getLatest().data and domoticz.data.lastGasMemory.getLatest().data ~= 0) then
            --only at 0:00 the value will be 0 (bug in domoticz) if 0 use the backup
            if(domoticz.devices(GasIDX).counter ~= 0) then
            
                --Calculate new value 201 = 200 + (101 - 100)
                TempGas = (domoticz.devices(GasIDX).counter*1000) + (CurrentGasQuantity - domoticz.data.lastGasMemory.getLatest().data)
                domoticz.data.BackupGas.add(TempGas)
            else
                TempGas = domoticz.data.BackupGas.getLatest().data + (CurrentGasQuantity - domoticz.data.lastGasMemory.getLatest().data)
                domoticz.data.BackupGas.add(TempGas)
            end
            
            --counter: Number. Value in m3
            --updateGas(usage): Function. Usage in dm3 (liters). Supports command options.
            domoticz.log('<font color="green">Gas from toon: ' .. TempGas/1000 .. 'm3', domoticz.LOG_INFO)
            domoticz.devices(GasIDX).updateGas(TempGas)
            
            --for next loop
            domoticz.data.lastGasMemory.add(CurrentGasQuantity)
        else 
            --lastKwehMemory is emtpy so no idea how much usage there was. set for next loop
            domoticz.data.lastGasMemory.add(CurrentGasQuantity)
        end
	end
}
Hi Eggybert
There is no data showing up in domoticz at my side. Can you help me out here?
I get the following information in the domoticz log:

2018-03-07 16:30:00.270 dzVents: Info: P1 toon: ------ Start internal script: P1 toon:, trigger: every minute
2018-03-07 16:30:00.282 dzVents: Info: P1 toon: No data from toon
2018-03-07 16:30:00.282 dzVents: Info: P1 toon: ------ Finished P1 toon

the url to from my toon returns the following information:
{
"dev_settings_device":{"uuid":"e1487b54-7dc2-4c93-a45a-22d88965da53", "name":"settings_device", "internalAddress":"settings_device", "type":"settings_device", "supportsCrc":"0", "location":"(null)"},
"dev_2":{"uuid":"4547cb41-7c14-438e-ab01-ac925db85af5", "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", "IsConnected":"1", "DeviceName":"", "HealthValue":"10", "location":"(null)"},
"dev_2.1":{"uuid":"186117b7-22bc-4582-aafb-46761b8070a8", "name":"HAE_METER_v2_1", "internalAddress":"2.1", "type":"gas", "supportsCrc":"0", "CurrentGasFlow":"90.00", "CurrentGasQuantity":"3088259.00", "location":"(null)"},
"dev_2.2":{"uuid":"778999db-cf9e-47bd-91dd-8aa53bc1a0e2", "name":"HAE_METER_v2_2", "internalAddress":"2.2", "type":"elec", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_2.3":{"uuid":"6f1f31ba-9650-40db-b7c9-729de830afe1", "name":"HAE_METER_v2_3", "internalAddress":"2.3", "type":"elec_delivered_nt", "supportsCrc":"0", "CurrentElectricityFlow":"388.00", "CurrentElectricityQuantity":"14258455.00", "location":"(null)"},
"dev_2.4":{"uuid":"c3e6e7dc-7997-4fdd-8a47-7029071e1a78", "name":"HAE_METER_v2_4", "internalAddress":"2.4", "type":"elec_received_nt", "supportsCrc":"0", "CurrentElectricityFlow":"0.00", "CurrentElectricityQuantity":"3773.00", "location":"(null)"},
"dev_2.5":{"uuid":"9f92dc88-93b9-475c-b630-e6104cba9412", "name":"HAE_METER_v2_5", "internalAddress":"2.5", "type":"elec_delivered_lt", "supportsCrc":"0", "CurrentElectricityFlow":"0.00", "CurrentElectricityQuantity":"17635602.00", "location":"(null)"},
"dev_2.6":{"uuid":"06ce1a22-b71e-4737-a7d1-f555fb444b4f", "name":"HAE_METER_v2_6", "internalAddress":"2.6", "type":"elec_received_lt", "supportsCrc":"0", "CurrentElectricityFlow":"0.00", "CurrentElectricityQuantity":"807.00", "location":"(null)"}
}
Regards

David
Hypermobile
Member
Member
Posts: 76
Joined: Sun Jan 14, 2018 5:12 pm

Re: Toon as a domotica controller?

Post by Hypermobile »

I think you need to Replace all Dev_3 into Dev_2

has something to do with Zwave channel...can be different fromt toon to toon
rudolfpi
Starting Member
Starting Member
Posts: 3
Joined: Mon Mar 19, 2018 7:58 pm

Re: Toon as a domotica controller?

Post by rudolfpi »

Hello MarcelR, can I contact you via PM or email?
marcelr
Global Moderator
Global Moderator
Posts: 1153
Joined: Thu May 10, 2012 10:58 pm
Location: Ehv

Re: Toon as a domotica controller?

Post by marcelr »

@rudolfpi
Unless it's top secret or embarrassing, you can ask whatever you like, right here.
Smiggel
Member
Member
Posts: 57
Joined: Wed Apr 11, 2018 2:20 pm

Re: Toon as a domotica controller?

Post by Smiggel »

Does this hack also work, when a Toon has been reset to factory settings and it prompting for activation? Have a Toon here that was reset to factory settings. I would like to unluck it. Will this work?
Smiggel
Member
Member
Posts: 57
Joined: Wed Apr 11, 2018 2:20 pm

Re: Toon as a domotica controller?

Post by Smiggel »

I have a Toon here that was reset to factory defaults. The main screen has a big green button that is requesting for an activation code. I was wondering if the hack will unlock the Toon features, even when my Toon is asking for the activation code now.

Can I unlock it and get rid of the activation button? It prefends me from browsing through my Toon now and don't want to get a subscription.
Toonz
Forum Moderator
Forum Moderator
Posts: 1873
Joined: Mon Dec 19, 2016 1:58 pm

Re: Toon as a domotica controller?

Post by Toonz »

Smiggel wrote:Can I unlock it and get rid of the activation button? It prefends me from browsing through my Toon now and don't want to get a subscription.
Yes, root the Toon and follow these steps to activate it:
viewtopic.php?f=87&t=11235&p=83254&hilit=scsync#p83254
member of the Toon Software Collective
Smiggel
Member
Member
Posts: 57
Joined: Wed Apr 11, 2018 2:20 pm

Re: Toon as a domotica controller?

Post by Smiggel »

Toonz wrote:
Smiggel wrote:Can I unlock it and get rid of the activation button? It prefends me from browsing through my Toon now and don't want to get a subscription.
Yes, root the Toon and follow these steps to activate it:
viewtopic.php?f=87&t=11235&p=83254&hilit=scsync#p83254
Ah thanks! That's good to know. Going to give it a try as soon as I have all the cables at home. :-)
mAiden
Member
Member
Posts: 330
Joined: Mon Jul 10, 2017 10:22 am

Re: Toon as a domotica controller?

Post by mAiden »

Maybe simple question but do not come out. :roll:

How can you switch a smart plug via hdrv_zwave?action=


EDIT:

Found already this url: http://TOON IP/hdrv_zwave?action=basicCommand&uuid=YOU CAN FIND THIS ON BY ?action=getDevices.json &state=_on (i try also on ;) )
My smart plug won't turn on.

EDIT2:

I find how i can do this:

You need: http://TOON IP/hdrv_zwave?action=basicCommand&uuid=YOU CAN FIND THIS ON BY ?action=getDevices.json &state=1 (1 = on 0 = off)
Member of the Toon Software Collective
Post Reply

Return to “Toon Rooting”