Page 1 of 1
script to check, it's not working
Posted: Tuesday 12 September 2023 22:19
by ssk17051980
on = {
devices = {
'81' -- Replace with the actual IDX of the switch
}
},
logging = {
level = domoticz.LOG_DEBUG, -- Can be changed to domoticz.LOG_INFO to reduce logging volume
},
execute = function(domoticz, device)
local sensorName = '200' -- Replace with the actual IDX of the water sensor
local areaInSquareMeters = 1 -- Replace with actual area in square meters
if device.state == 'On' then
local amountOfWater = 0.52615 * areaInSquareMeters -- Calculates the amount of water
domoticz.devices(sensorName).updateCustomSensor(amountOfWater) -- Updates the custom water sensor
domoticz.log('Amount of water added: ' .. amountOfWater .. ' L', domoticz.LOG_DEBUG)
end
end
}
can somebody to corect the script ?
thx
Re: script to check, it's not working
Posted: Tuesday 12 September 2023 22:36
by HvdW
check this example
Code: Select all
return
{
on =
{
devices = { 'Room switch'}
},
execute = function(domoticz, roomSwitch)
if (roomSwitch.active and domoticz.devices('Living room').temperature > 18) then
domoticz.devices('Another switch').switchOn()
domoticz.notify('This rocks!',
'Turns out that it is getting warm here',
domoticz.PRIORITY_LOW)
end
}
look where you place the braces
Re: script to check, it's not working
Posted: Wednesday 13 September 2023 1:28
by waltervl
I linked you to this script
viewtopic.php?p=255592#p255592
Why did you not use that?
And if something is not working please indicate what is not working. But better use the script I linked to.
Make a dummy rain device (in the script named 'regenmeter').
Re: script to check, it's not working
Posted: Wednesday 13 September 2023 11:13
by ssk17051980
I created the virtual sensor with the name regenmeter. I replaced the tippingbucketrain name with Terrace in the script, this being the element that transmits the information.
still no response from the dummy
return
{
on =
{
devices =
{
"tippingbucketrain",
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- INFO, ERROR or DEBUG
marker = "ESP test",
},
execute = function(dz, item)
local rainDevice = dz.devices("Regenmeter") -- Your (virtual) rain device
local rainSwitch = dz.devices("Terasa") -- Your (triggered by bucket full) switch
local rainmm = 2 -- find out what 1 bucket full means in terms of mm
local rainTotal = 0
local timeSlice = math.min( (rainDevice.lastUpdate.secondsAgo / 3600), 10) -- at least 1 bucket in 10 hours
local rainAmountHour = dz.utils.round((rainmm / timeSlice),1)
if item.active then
rainTotal = dz.utils.round((rainmm + rainDevice.rain),1)
rainDevice.updateRain(rainAmountHour, rainTotal)
dz.log("One bucket full ==>> updating raindevice. rainrate: " .. rainAmountHour .. " mm/hr, " .. rainTotal .." mm in total today ", dz.LOG_DEBUG )
rainSwitch.switchOff().silent()
end
end
}
Re: script to check, it's not working
Posted: Wednesday 13 September 2023 19:50
by waltervl
As indicated please put code into brackets.
You did not replace tippingbicketrain to Terasa everywhere in the script. So the script will not be triggered when Terasa is switched.