Page 37 of 39
Re: Toon as a domotica controller?
Posted: Sun Feb 11, 2018 12:55 pm
by Hypermobile
michel30 wrote:@glsf91
I use your scrip for my analog meter the GAS and POWER from TOON to Domoticz works super.
I also see in Domoticz you can add the price from your provider, do you know how I can show this part in Domoticz? so I have the GAS and POWER price in Toon.
Maybe create another Dummy device; and multiply KWH with some Pricevalue; and shoot in into that Dummy device.
personally i'm not interested in cost, only in usage.
if you don't waste on usage you automatically don't overpay
Re: Toon as a domotica controller?
Posted: Sun Feb 11, 2018 1:27 pm
by michel30
Hello,
The use of KWH or M3 was allready working.
I was only was searching how I can see the price on domoticz and that works now okay
On Domoticz is it match faster and easy to see how match you used in a week than on the Toon.
Re: Toon as a domotica controller?
Posted: Wed Feb 14, 2018 9:01 pm
by Eggybert
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
)
*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
}
Re: Toon as a domotica controller?
Posted: Thu Feb 15, 2018 8:16 am
by Hypermobile
Make sure; DZvents is Enabled in Settings
PHP-Script is Discontinued. not necessary anymore
It's works like a charm (non P1)
Eggybert wil post the Script soon...
Re: Toon as a domotica controller?
Posted: Fri Feb 16, 2018 1:21 pm
by gielie
I use the non P1 version and for elec its working fine (except the daily usage is a 1000 fold too high) but i won't get any gas values.
this is the error
Code: Select all
2018-02-16 12:19:00.444 dzVents: Info: Power toon: ------ Start internal script: Toon backup:, trigger: every minute
2018-02-16 12:19:00.589 dzVents: Debug: Power toon: Processing device-adapter for Stroom2: kWh device adapter
2018-02-16 12:19:00.590 dzVents: Info: Power toon: Power from toon: 4380.806kwh USAGE | 364w consumed |
2018-02-16 12:19:00.592 dzVents: Debug: Power toon: Processing device-adapter for gas2: Gas device adapter
2018-02-16 12:19:00.593 dzVents: Error (2.4.1): Power toon: An error occured when calling event handler Toon backup
2018-02-16 12:19:00.593 dzVents: Error (2.4.1): Power toon: ...moticz/scripts/dzVents/generated_scripts/Toon backup.lua:116: attempt to perform arithmetic on global 'BackupGas' (a nil value)
2018-02-16 12:19:00.593 dzVents: Info: Power toon: ------ Finished Toon backup
When i look at the output of my toon i get this
Code: Select all
{
"dev_settings_device":{"uuid":"eneco-001-003065:hdrv_zwave_722E1463E52", "name":"settings_device", "internalAddress":"settings_device", "type":"settings_device", "supportsCrc":"0", "location":"(null)"},
"dev_3":{"uuid":"eneco-001-003065:hdrv_zwave_72262C23F3F", "name":"HAE_METER_v2", "internalAddress":"3", "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", "HealthValue":"1", "DeviceName":"", "location":"(null)"},
"dev_3.1":{"uuid":"eneco-001-003065:hdrv_zwave_72227F83F45", "name":"HAE_METER_v2_1", "internalAddress":"3.1", "type":"gas", "supportsCrc":"0", "ccList":"3c 3d 3e 72 86", "supportedCC":"3c 3d 3e 72 86", "CurrentGasFlow":"0.00", "CurrentGasQuantity":"98200.00", "location":"(null)"},
"dev_3.2":{"uuid":"eneco-001-003065:hdrv_zwave_722E9E83F45", "name":"HAE_METER_v2_2", "internalAddress":"3.2", "type":"elec", "supportsCrc":"0", "CurrentElectricityFlow":"266.00", "CurrentElectricityQuantity":"221461.00", "location":"(null)"},
"dev_3.3":{"uuid":"eneco-001-003065:hdrv_zwave_722438D3F45", "name":"HAE_METER_v2_3", "internalAddress":"3.3", "type":"elec_delivered_nt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.4":{"uuid":"eneco-001-003065:hdrv_zwave_722255A3F45", "name":"HAE_METER_v2_4", "internalAddress":"3.4", "type":"elec_received_nt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.5":{"uuid":"eneco-001-003065:hdrv_zwave_72272633F45", "name":"HAE_METER_v2_5", "internalAddress":"3.5", "type":"elec_delivered_lt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"},
"dev_3.6":{"uuid":"eneco-001-003065:hdrv_zwave_722D79F3F45", "name":"HAE_METER_v2_6", "internalAddress":"3.6", "type":"elec_received_lt", "supportsCrc":"0", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"}
}
What is the problem here?
Re: Toon as a domotica controller?
Posted: Fri Feb 16, 2018 5:32 pm
by Eggybert
Changed the scrip so the gas should work now. Not sure why the electricity is going wrong at the moment
Re: Toon as a domotica controller?
Posted: Fri Feb 16, 2018 6:13 pm
by Hypermobile
Eggyberts script. so credits are for him
We disagree on using UserVariables; but i think there is a bug in Domoticz.
I Got stranges values as well. This script worked for at least 3 days correct.
It's a Domoticz Event > DZ Vents.
Non P1, ANALOG reads from toon to domoticz.
UnDisable DZVents in Domoticz>settings>other.
Set DZvents-Logsettings: "Errors + minimal excetution info+generic info" for DZ vents in Domoticz>Settings>other
Create User variables in Domoticz; look in the script for the correct names.
Set correct IDX to Write to
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 = {
--Als er alleen data ouder is dan 15 min iets doen
lastKwhMemory = { history = true, maxItems = 1 },
lastGasMemory = { history = true, maxItems = 1 }
},
execute = function(domoticz)
local ToonIP = domoticz.variables('UV_ToonIP').value --192.168.0.*
local DomoticzIP = domoticz.variables('UV_DomoticzIP').value --192.168.0.*:8084
local KwhMemory = domoticz.variables('UV_TotalPower').value --interger 0
local GasMemory = domoticz.variables('UV_TotalGas').value --interger 0
local GasIDX = 371
local ElectricityIDX = 372
--Replace all dev_3 for your number you can find @ http://TOONIP/hdrv_zwave?action=getDevices
--Replace IDX number to your IDX numers. Gas and electic instance/counter
--make the User Valriables above (TotalPower and TotalGas are integers 0, ToonIP is a string, DomoticzIP is a string with IP:port 192.168.0.*:8084)
--Handle json
--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
local handle = assert(io.popen(string.format('curl http://%s/hdrv_zwave?action=getDevices.json', ToonIP)))
local ZwaveInfo = handle:read('*all')
handle:close()
-- remove the .
ZwaveInfo = string.gsub(ZwaveInfo, "dev_3.", "dev_3")
ZwaveInfo = string.gsub(ZwaveInfo, "dev_3:", "dev_3\":")
local jsonZwaveInfo = json:decode(ZwaveInfo)
if jsonZwaveInfo == nil then
domoticz.log('<font color="green">No data from Toon', domoticz.LOG_INFO)
return
end
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
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(CurrentElectricityQuantity >= domoticz.data.lastKwhMemory.getLatest().data and domoticz.data.lastKwhMemory.getLatest().data ~= 0) then
--Calculate new value 201 = 200(user variable) + (101(new value) - 100(memory last loop))
TempElectricity = KwhMemory + (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)
--update user variable to current value
--domoticz.variables('UV_ToonKwh').set(TempElectricity)
domoticz.openURL(string.format('http://%s/json.htm?type=command¶m=updateuservariable&vname=UV_TotalPower&vtype=0&vvalue=%d',DomoticzIP,TempElectricity))
--for next loop
domoticz.data.lastKwhMemory.add(CurrentElectricityQuantity)
else
--lastKwehMemory is emtpy so no idea how much usage there was. set for next loop
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
--Calcukate new value 201 = 200 + (101 - 100)
TempGas = GasMemory + (CurrentGasQuantity - domoticz.data.lastGasMemory.getLatest().data)
--counter: Number. Value in m3
--counterToday: 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)
--update user variable to current value
--domoticz.variables('UV_ToonGas').set(TempGas) --due to Domoticz bug it doesn't work on synology alternative below.
domoticz.openURL(string.format('http://%s/json.htm?type=command¶m=updateuservariable&vname=UV_TotalGas&vtype=0&vvalue=%d',DomoticzIP,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
}
Re: Toon as a domotica controller?
Posted: Sat Feb 17, 2018 10:21 am
by Hypermobile
Something else:
Is there a way to Toggle the Switch 'tap water' by a Json command?
I would like to run some tests.
To switch it off in Domoticz when we're not at home
Re: Toon as a domotica controller?
Posted: Sat Feb 17, 2018 1:27 pm
by TheHogNL
Try the url /happ_thermstat?action=setBoilerOnOff&state=off
I don't have opentherm so couldn't check with my Toon but I think this is the one.
Re: Toon as a domotica controller?
Posted: Sat Feb 17, 2018 2:24 pm
by Hypermobile
TheHogNL wrote:Try the url /happ_thermstat?action=setBoilerOnOff&state=off
I don't have opentherm so couldn't check with my Toon but I think this is the one.
{"result":"ok"}
but switch stay's 'on'
Re: Toon as a domotica controller?
Posted: Sat Feb 17, 2018 6:43 pm
by TheHogNL
Ok then this is doing something else
I have seen on another Toon that it does send a boiler off or on command to opentherm. Maybe it is supposed to turn of the whole boiler itself or not, depening if the boiler accepts the command.
Re: Toon as a domotica controller?
Posted: Sun Feb 18, 2018 11:27 am
by TheHogNL
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.
Re: Toon as a domotica controller?
Posted: Sun Feb 18, 2018 9:24 pm
by glsf91
I made a dzVents script in Domoticz to get "Graaddagen" in Domoticz.
It is getting information from KNMI for a weatherstation nearby. It will be saved to a custom sensor(name: Graaddagen) which you have to create.
The "graaddag" from yesterday is saved on today's date (is not possible to save to yesterday) and also visible for today in the graph.
You have to change the station. You can find station number here:
http://projects.knmi.nl/klimatologie/uurgegevens/.
Script is non blocking for Domoticz. Hangt Domoticz will not blocked if site is not available.
Script is running 2 times a day. One time to get data and 1 minute later again to process data.
Don't start too early because data is not immediately available.
You can change the name of the sensor at the bottom if this script.
Code: Select all
-- meer info hier: http://www.knmi.nl/kennis-en-datacentrum/achtergrond/data-ophalen-vanuit-een-script
-- stations: http://projects.knmi.nl/klimatologie/uurgegevens/
local ResultFile = '/var/tmp/tmpknmi.txt' -- Temporary file to store the servers response
local fetchIntervalMins = 5 -- don't change
local scriptVersion = '1.0.0'
local station = 267
local meanTemperatureInside = 18
local function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end
return {
active = true,
logging = {
level = domoticz.LOG_INFO, -- Uncomment to override the dzVents global logging setting
marker = 'Graaddagen '..scriptVersion
},
on = {
timer = { 'at 08:05-08:07'} -- warning: don't change the last number 5 and 7
},
execute = function(domoticz, device)
-- When time, call the URL and exit.
-- The following minute, return to read the result file
local callUrl = false
if (os.date('*t').min % fetchIntervalMins) == 0 then
callUrl = true
elseif ((os.date('*t').min -1) % fetchIntervalMins) ~= 0 then
--return
end
previousday = os.date('%Y%m%d', os.time() - 60*60*24)
if callUrl then
local url = 'http://projects.knmi.nl/klimatologie/daggegevens/getdata_dag.cgi'
startdate = os.date('%Y%m%d', os.time() - 2*60*60*24)
local data = 'vars=TG&start='..startdate..'&end='..previousday..'&stns='..station
domoticz.log('Requesting data from the knmi server...', domoticz.LOG_INFO)
domoticz.log('URL used: '..url, domoticz.LOG_DEBUG)
domoticz.log('DATA used: '..data, domoticz.LOG_DEBUG)
os.execute('curl --data "'..data..'" -s "'..url..'" > '..ResultFile..'&')
return -- Nothing more to do for now, we'll be back in a minute to read the data!
end
---loads a json file with the provided name and returns it as a table (if it exists)
local function readLuaFromFile(fileName)
local month = tonumber(os.date('%m'))
if ((month >= 4) and (month <= 9)) then
weegfactor = 0.8
elseif ((month == 3) or (month == 10)) then
weegfactor = 1.0
else
weegfactor = 1.1
end
local file = io.open(fileName, 'r')
if file then
while true do
local line = file:read("*line")
if not line then break end
if debug then domoticz.log('Line:'..line, domoticz.LOG_DEBUG) end
-- skip lines starting with #
if not string.find(line, "#", 1) then
linestation, linedate, linegraden = string.match(tostring(line), '([0-9]*),([0-9]*), *([-0-9]*)')
domoticz.log('linestation:'..linestation, domoticz.LOG_DEBUG)
domoticz.log('linedate:'..linedate, domoticz.LOG_DEBUG)
domoticz.log('linegraden:'..linegraden, domoticz.LOG_DEBUG)
graden = tonumber(linegraden)/10
domoticz.log('graden:'..graden, domoticz.LOG_DEBUG)
difference = os.difftime (linedate,previousday)
domoticz.log('previousday:'..previousday, domoticz.LOG_DEBUG)
domoticz.log('difference date:'..difference, domoticz.LOG_DEBUG)
-- get only line from yesterday
if (difference == 0 ) then
io.close(file)
if graden >= meanTemperatureInside then
return 0
end
return round((meanTemperatureInside - graden) * weegfactor,0)
end
end
end
io.close(file)
end
return nil
end
local graadgraden = readLuaFromFile(ResultFile)
if not graadgraden then
domoticz.log('Could not read data from file or not data for yesterday available: '.. ResultFile, domoticz.LOG_ERROR)
return
end
domoticz.log('Result graaddagen: '..graadgraden, domoticz.LOG_INFO)
domoticz.devices('Graaddagen').updateCustomSensor(graadgraden) -- change sensor name
end
}
Re: Toon as a domotica controller?
Posted: Sat Feb 24, 2018 12:37 am
by michel30
Hello,
After an upgrade I have an issue with viewing this webpage: http://TOON_IP/happ_pwrusage?action=GetCurrentUsage the issue is 403 - Forbidden
I had it also for the other 4 site, but that is fixed by editing an extra line in edit qmf_release.xml with <item>happ_thermstat</item>
I have only the problem for http://TOON_IP/happ_pwrusage?action=GetCurrentUsage
Re: Toon as a domotica controller?
Posted: Sun Feb 25, 2018 3:04 pm
by michel30
michel30 wrote:Hello,
After an upgrade I have an issue with viewing this webpage: http://TOON_IP/happ_pwrusage?action=GetCurrentUsage the issue is 403 - Forbidden
I had it also for the other 4 site, but that is fixed by editing an extra line in edit qmf_release.xml with <item>happ_thermstat</item>
I have only the problem for http://TOON_IP/happ_pwrusage?action=GetCurrentUsage
My problem is solved by installing the latest ToonStore and now the webpage happ_pwrusage?action=GetCurrentUsage is working.