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.
Energy Meter and Notifications [Solved]
Moderator: leecollings
-
- Posts: 7
- Joined: Thursday 14 July 2016 11:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
Energy Meter and Notifications
Raspberry Pi 3 and Pi 4 - Pi Camera - DS18B20 - HC-SR501 - FGMS-001 - Telegram Bot
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Energy Meter and Notifications
Could look likeFeybio 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?
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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 7
- Joined: Thursday 14 July 2016 11:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
Re: Energy Meter and Notifications
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
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
Raspberry Pi 3 and Pi 4 - Pi Camera - DS18B20 - HC-SR501 - FGMS-001 - Telegram Bot
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Energy Meter and Notifications
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 ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 7
- Joined: Thursday 14 July 2016 11:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
Re: Energy Meter and Notifications
Raspberry Pi 3 - Buster
Domoticz 2020.2
AEON Labs ZW090 Z-Stick Gen5 EU
AEON Labs DSB28 Home Energy Meter (2nd Edition)
Domoticz 2020.2
AEON Labs ZW090 Z-Stick Gen5 EU
AEON Labs DSB28 Home Energy Meter (2nd Edition)
- Attachments
-
- Watts.png (36.81 KiB) Viewed 1055 times
Raspberry Pi 3 and Pi 4 - Pi Camera - DS18B20 - HC-SR501 - FGMS-001 - Telegram Bot
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Energy Meter and Notifications
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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 7
- Joined: Thursday 14 July 2016 11:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
Re: Energy Meter and Notifications [Solved]
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.
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.
Raspberry Pi 3 and Pi 4 - Pi Camera - DS18B20 - HC-SR501 - FGMS-001 - Telegram Bot
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Energy Meter and Notifications
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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest