Page 1 of 1
Energy Meter and Notifications
Posted: Monday 03 August 2020 8:55
by Feybio
Hi all
My energy supplier turns off the power if I exceed 3990 Watt for more than 2 minutes.
I created a Telegram notification to be alerted if this happens and works perfectly.
The energy meter reads the value every 5 seconds, the problem is as follows:
Values:
3512
3670
4001 (telegram notification)
3847
3798
As soon as I exceed the set value (3990) I am warned even if the subsequent values indicate that it was only a peak.
Is there a way, via script (lua, blokly ...), to receive the notification only if
2 or more consecutive values are greater than 3990 watts?
Thank you.
Re: Energy Meter and Notifications
Posted: Monday 03 August 2020 10:17
by waaren
Feybio wrote: ↑Monday 03 August 2020 8:55
My energy supplier turns off the power if I exceed 3990 Watt for more than 2 minutes.
I created a Telegram notification to be alerted if this happens and works perfectly.
As soon as I exceed the set value (3990) I am warned even if the subsequent values indicate that it was only a peak.
Is there a way, via script (lua, blokly ...), to receive the notification only if
2 or more consecutive values are greater than 3990 watts?
Could look like
Code: Select all
return
{
on =
{
devices =
{
'Power', -- Change to name of your smartmeter
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all ok
marker = 'managed notification',
},
data =
{
consecutiveHighReads =
{
initial = 0,
},
},
execute = function(dz, item)
local alertFence = 3990 -- change to your higfence
local maxConsecutiveReadings = 2 -- change to max number of consecutive high reading.
if item.usage > alertFence then
dz.data.consecutiveHighReads = dz.data.consecutiveHighReads + 1
if dz.data.consecutiveHighReads == maxConsecutiveReadings then
dz.notify('Smartmeter','Power usage too high ( > ' .. alertFence .. ' ) for ' .. maxConsecutiveReadings .. ' consecutive readings.',nil,nil,nil,dz.NSS_TELEGRAM)
end
elseif dz.data.consecutiveHighReads > 0 then
dz.data.consecutiveHighReads = 0
end
end
}
Re: Energy Meter and Notifications
Posted: Monday 03 August 2020 11:06
by Feybio
Thank you, i got an error on line 29
if item.usage > alertFence then
2020-08-03 11:06:21.609 Error: dzVents: Error: (3.0.2) managed notification: ...Domoticz/scripts/dzVents/generated_scripts/Script #1.lua:29: attempt to compare number with nil
Re: Energy Meter and Notifications
Posted: Monday 03 August 2020 11:23
by waaren
Feybio wrote: ↑Monday 03 August 2020 11:06
2020-08-03 11:06:21.609 Error: dzVents: Error: (3.0.2) managed notification: ...Domoticz/scripts/dzVents/generated_scripts/Script #1.lua:29: attempt to compare number with nil
I assumed you energy meter is a smart meter. If you get this error it obviously is another type / subtype. Can you look at the devices tab to see what the device type and subtype of your energy meter is ?
Re: Energy Meter and Notifications
Posted: Monday 03 August 2020 11:40
by Feybio
Raspberry Pi 3 - Buster
Domoticz 2020.2
AEON Labs ZW090 Z-Stick Gen5 EU
AEON Labs DSB28 Home Energy Meter (2nd Edition)
Re: Energy Meter and Notifications
Posted: Monday 03 August 2020 12:32
by waaren
Feybio wrote: ↑Monday 03 August 2020 11:40
Raspberry Pi 3 - Buster
Domoticz 2020.2
AEON Labs ZW090 Z-Stick Gen5 EU
AEON Labs DSB28 Home Energy Meter (2nd Edition)
Thx. Can you try with this one?
Code: Select all
return
{
on =
{
devices =
{
'Watts', -- Change to name of your smartmeter
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all ok
marker = 'managed notification',
},
data =
{
consecutiveHighReads =
{
initial = 0,
},
},
execute = function(dz, item)
local alertFence = 3990 -- change to your higfence
local maxConsecutiveReadings = 2 -- change to max number of consecutive high reading.
if item.actualWatt > alertFence then
dz.data.consecutiveHighReads = dz.data.consecutiveHighReads + 1
if dz.data.consecutiveHighReads == maxConsecutiveReadings then
dz.notify('Smartmeter','Power usage too high ( > ' .. alertFence .. ' ) for ' .. maxConsecutiveReadings .. ' consecutive readings.',nil,nil,nil,dz.NSS_TELEGRAM)
end
elseif dz.data.consecutiveHighReads > 0 then
dz.data.consecutiveHighReads = 0
end
end
}
Re: Energy Meter and Notifications [Solved]
Posted: Tuesday 04 August 2020 7:52
by Feybio
Thanks a lot waaren, your script work perfectly!
Edit:
I need pls your help for the last implementation...
Its possibile to add another line after the notification is triggered that excecut a python script with a passed variable (actualWatt)?
Something like this:
- dz.notify('Smartmeter','Power usage too high ( > ' .. alertFence .. ' ) for ' .. maxConsecutiveReadings .. ' consecutive readings.',nil,nil,nil,dz.NSS_TELEGRAM)
- python /home/pi/Allarm/Script.py "item.actualWatt"
Sorry i'm very new to DzVents.
Re: Energy Meter and Notifications
Posted: Tuesday 04 August 2020 9:03
by waaren
Feybio wrote: ↑Tuesday 04 August 2020 7:52
I need pls your help for the last implementation...
Its possibile to add another line after the notification is triggered that excecut a python script with a passed variable (actualWatt)?
Yes, could be something like
Code: Select all
return
{
on =
{
devices =
{
'Watts', -- Change to name of your energy meter
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all ok
marker = 'managed notification',
},
data =
{
consecutiveHighReads =
{
initial = 0,
},
},
execute = function(dz, item)
local alertFence = 3990 -- change to your highfence
local maxConsecutiveReadings = 2 -- change to max number of consecutive high reading.
if item.actualWatt > alertFence then
dz.data.consecutiveHighReads = dz.data.consecutiveHighReads + 1
if dz.data.consecutiveHighReads == maxConsecutiveReadings then
dz.notify('Smartmeter','Power usage too high ( > ' .. alertFence .. ' ) for ' .. maxConsecutiveReadings .. ' consecutive readings.',nil,nil,nil,dz.NSS_TELEGRAM)
local cmd = 'python /home/pi/Allarm/Script.py ' .. item.actualWatt .. ' &'
os.execute(cmd)
end
elseif dz.data.consecutiveHighReads > 0 then
dz.data.consecutiveHighReads = 0
end
end
}