Notification time overcoming Watt  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
djdevil
Posts: 101
Joined: Friday 26 July 2019 18:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Notification time overcoming Watt

Post by djdevil »

Hi all, I would need a script that when I exceed 4000watt for more than 3 minutes I am notified, you can help me thanks :idea:
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Notification time overcoming Watt

Post by waaren »

djdevil wrote: Saturday 16 May 2020 20:03 Hi all, I would need a script that when I exceed 4000watt for more than 3 minutes I am notified, you can help me thanks :idea:
What is the device name, type and subtype of the device you want to be warned about ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
djdevil
Posts: 101
Joined: Friday 26 July 2019 18:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Notification time overcoming Watt

Post by djdevil »

waaren wrote: Sunday 17 May 2020 1:44
djdevil wrote: Saturday 16 May 2020 20:03 Hi all, I would need a script that when I exceed 4000watt for more than 3 minutes I am notified, you can help me thanks :idea:
What is the device name, type and subtype of the device you want to be warned about ?
hello waaren thx for reply

device name is : Consumo generale and is power meter type
Immagine.png
Immagine.png (16.4 KiB) Viewed 1627 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Notification time overcoming Watt

Post by waaren »

djdevil wrote: Sunday 17 May 2020 13:23 device name is : Consumo generale and is power meter type
Immagine.png
Can you please state the type / subtype as in the devices tab and in English like below
devices.tab
devices.tab
devices tab.png (78.54 KiB) Viewed 1619 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
djdevil
Posts: 101
Joined: Friday 26 July 2019 18:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Notification time overcoming Watt

Post by djdevil »

waaren wrote: Sunday 17 May 2020 17:44
djdevil wrote: Sunday 17 May 2020 13:23 device name is : Consumo generale and is power meter type
Immagine.png
Can you please state the type / subtype as in the devices tab and in English like below

devices tab.png
oh yes type "General" SubType "kWh"
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Notification time overcoming Watt  [Solved]

Post by waaren »

djdevil wrote: Sunday 17 May 2020 18:40 oh yes type "General" SubType "kWh"
Can you try this one ?

Code: Select all

local scriptVar = 'wattNotification'

return
{
    on =
    {
        devices =
        {
            'wattDevice', -- change to name of device to monitor
        },
        customEvents =
        {
            scriptVar,
        },
    },

    data =
    {
        watt =
        {
                history = true,
                maxMinutes = 5,
        },
        notificationsSend =
        {
                history = true,
                maxHours = 4,         -- Only 1 notification every 4 hours change to how many you want
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- change to doomticz.LOG_ERROR when script works without issues
    },

    execute = function(dz, item)
        local maxWatt = 4000
        local highMinutes = 3

        if item.isDevice then
            dz.data.watt.add(item.actualWatt)
            -- item.dump() only for debugging
            if item.actualWatt > maxWatt then
                dz.emitEvent(scriptVar).afterMin(highMinutes)
            end
        else
            if ( dz.data.watt.minSince('00:03:00') > maxWatt ) and ( dz.data.notificationsSend.sum() < 1 ) then
                dz.notify('maxWatt','usage over ' .. maxWatt .. ' watt, for over ' .. highMinutes ..' minutes')
                dz.data.notificationsSend.add(1)
            end
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
djdevil
Posts: 101
Joined: Friday 26 July 2019 18:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Notification time overcoming Watt

Post by djdevil »

I have tried the script works perfectly. thank you so much, you solved me a big problem. you are the best thanks :D
User avatar
djdevil
Posts: 101
Joined: Friday 26 July 2019 18:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Notification time overcoming Watt

Post by djdevil »

waaren since I activated the script I find all these events in the log, I also tried to deactivate with domoticz.LOG_ERROR but there is no way to hide them. How can I do thanks


Code: Select all

 2020-05-18 00:38:12.358 Status: dzVents: > setNightMode()
2020-05-18 00:38:12.358 Status: dzVents: > updateDistance()
2020-05-18 00:38:12.358 Status: dzVents: > open()
2020-05-18 00:38:12.358 Status: dzVents: > updateBarometer()
2020-05-18 00:38:12.358 Status: dzVents: > updateWind()
2020-05-18 00:38:12.358 Status: dzVents: > updateSoundLevel()
2020-05-18 00:38:12.358 Status: dzVents: > updateGas()
2020-05-18 00:38:12.358 Status: dzVents: > active: false
2020-05-18 00:38:12.358 Status: dzVents: > hardwareName: Shelly
2020-05-18 00:38:12.358 Status: dzVents: > kodiPlayPlaylist()
2020-05-18 00:38:12.358 Status: dzVents: > setIcon()
2020-05-18 00:38:12.358 Status: dzVents: > updateTempBaro()
2020-05-18 00:38:12.358 Status: dzVents: > protected: false
2020-05-18 00:38:12.358 Status: dzVents: > setColorBrightness()
2020-05-18 00:38:12.358 Status: dzVents: > sValue: 471.4;1589880.1
2020-05-18 00:38:12.358 Status: dzVents: > protectionOff()
2020-05-18 00:38:12.358 Status: dzVents: > isDevice: true
2020-05-18 00:38:12.358 Status: dzVents: > dimTo()
2020-05-18 00:38:12.358 Status: dzVents: > dump()
2020-05-18 00:38:12.358 Status: dzVents: > setValues()
2020-05-18 00:38:12.358 Status: dzVents: > getColor()
2020-05-18 00:38:12.358 Status: dzVents: > updateWetness()
2020-05-18 00:38:12.358 Status: dzVents: > setVolume()
2020-05-18 00:38:12.358 Status: dzVents: > startPlaylist()
2020-05-18 00:38:12.359 Status: dzVents: > isScene: false
2020-05-18 00:38:12.359 Status: dzVents: > isSecurity: false
2020-05-18 00:38:12.359 Status: dzVents: > updateCustomSensor()
2020-05-18 00:38:12.359 Status: dzVents: > setWhiteMode()
2020-05-18 00:38:12.359 Status: dzVents: > updateTempHum()
2020-05-18 00:38:12.359 Status: dzVents: > setKelvin()
2020-05-18 00:38:12.359 Status: dzVents: > _nValue: 0
2020-05-18 00:38:12.359 Status: dzVents: > protectionOn()
2020-05-18 00:38:12.359 Status: dzVents: > quietOff()
2020-05-18 00:38:12.359 Status: dzVents: > updatePressure()
2020-05-18 00:38:12.359 Status: dzVents: > volumeUp()
2020-05-18 00:38:12.359 Status: dzVents: > kodiPlay()
2020-05-18 00:38:12.359 Status: dzVents: > state: 471.4;1589880.1
2020-05-18 00:38:12.359 Status: dzVents: > decreaseBrightness()
2020-05-18 00:38:12.359 Status: dzVents: > updateWeight()
2020-05-18 00:38:12.359 Status: dzVents: > updateRadiation()
2020-05-18 00:38:12.359 Status: dzVents: > updateRain()
2020-05-18 00:38:12.359 Status: dzVents: > updateYouless()
2020-05-18 00:38:12.359 Status: dzVents: > icon: current
2020-05-18 00:38:12.359 Status: dzVents: > setRGB()
2020-05-18 00:38:12.359 Status: dzVents: > hardwareTypeValue: 94
2020-05-18 00:38:12.359 Status: dzVents: > deviceSubType: kWh
2020-05-18 00:38:12.359 Status: dzVents: > kodiSetVolume()
2020-05-18 00:38:12.359 Status: dzVents: > WhActual: 471.4
2020-05-18 00:38:12.359 Status: dzVents: > updateAlertSensor()
2020-05-18 00:38:12.359 Status: dzVents: > setHotWater()
2020-05-18 00:38:12.359 Status: dzVents: > updateElectricity()
2020-05-18 00:38:12.359 Status: dzVents: > actualWatt: 471.4
2020-05-18 00:38:12.359 Status: dzVents: > WhToday: 356.0
2020-05-18 00:38:12.359 Status: dzVents: > _adapters:
2020-05-18 00:38:12.359 Status: dzVents: > 1: kWh device adapter
2020-05-18 00:38:12.359 Status: dzVents: > rename()
2020-05-18 00:38:12.359 Status: dzVents: > kodiExecuteAddOn()
2020-05-18 00:38:12.359 Status: dzVents: > counterToday: 0.356
2020-05-18 00:38:12.359 Status: dzVents: > deviceType: General
2020-05-18 00:38:12.359 Status: dzVents: > armAway()
2020-05-18 00:38:12.359 Status: dzVents: > setState()
2020-05-18 00:38:12.359 Status: dzVents: > kodiPlayFavorites()
2020-05-18 00:38:12.359 Status: dzVents: > update()
2020-05-18 00:38:12.359 Status: dzVents: > quietOn()
2020-05-18 00:38:12.359 Status: dzVents: > setDescription()
2020-05-18 00:38:12.360 Status: dzVents: > _state: 471.4;1589880.1
2020-05-18 00:38:12.360 Status: dzVents: > kodiPause()
2020-05-18 00:38:12.360 Status: dzVents: > updateText()
2020-05-18 00:38:12.360 Status: dzVents: > kodiStop()
2020-05-18 00:38:12.360 Status: dzVents: > setHex()
2020-05-18 00:38:12.360 Status: dzVents: > updateMode()
2020-05-18 00:38:12.360 Status: dzVents: > updateUV()
2020-05-18 00:38:12.360 Status: dzVents: > isTimer: false
2020-05-18 00:38:12.360 Status: dzVents: > updateTempHumBaro()
2020-05-18 00:38:12.360 Status: dzVents: > isGroup: false
2020-05-18 00:38:12.360 Status: dzVents: > idx: 580
2020-05-18 00:38:12.360 Status: dzVents: > timedOut: false
2020-05-18 00:38:12.360 Status: dzVents: > updateLux()
2020-05-18 00:38:12.360 Status: dzVents: > id: 580
2020-05-18 00:38:12.360 Status: dzVents: > description:
2020-05-18 00:38:12.360 Status: dzVents: > hardwareType: Shelly MQTT
2020-05-18 00:38:12.360 Status: dzVents: > armHome()
2020-05-18 00:38:12.360 Status: dzVents: > volumeDown()
2020-05-18 00:38:12.360 Status: dzVents: > switchTypeValue: 0
2020-05-18 00:38:12.360 Status: dzVents: > close()
2020-05-18 00:38:12.360 Status: dzVents: > reset()
2020-05-18 00:38:12.360 Status: dzVents: > baseType: device
2020-05-18 00:38:12.360 Status: dzVents: > setColor()
2020-05-18 00:38:12.360 Status: dzVents: > switchOff()
2020-05-18 00:38:12.360 Status: dzVents: > rawData:
2020-05-18 00:38:12.360 Status: dzVents: > 1: 471.4
2020-05-18 00:38:12.360 Status: dzVents: > 2: 1589880.1
2020-05-18 00:38:12.360 Status: dzVents: > updatePercentage()
2020-05-18 00:38:12.360 Status: dzVents: > unit: 10
2020-05-18 00:38:12.360 Status: dzVents: > updateWaterflow()
2020-05-18 00:38:12.360 Status: dzVents: > playFavorites()
2020-05-18 00:38:12.360 Status: dzVents: > pause()
2020-05-18 00:38:12.360 Status: dzVents: > updateHumidity()
2020-05-18 00:38:12.360 Status: dzVents: > updateP1()
2020-05-18 00:38:12.360 Status: dzVents: > nValue: 0 
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Notification time overcoming Watt

Post by waaren »

djdevil wrote: Monday 18 May 2020 0:41 waaren since I activated the script I find all these events in the log, I also tried to deactivate with domoticz.LOG_ERROR but there is no way to hide them. How can I do thanks
Remove the line with item.dump()
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
djdevil
Posts: 101
Joined: Friday 26 July 2019 18:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Contact:

Re: Notification time overcoming Watt

Post by djdevil »

waaren wrote: Monday 18 May 2020 1:57
djdevil wrote: Monday 18 May 2020 0:41 waaren since I activated the script I find all these events in the log, I also tried to deactivate with domoticz.LOG_ERROR but there is no way to hide them. How can I do thanks
Remove the line with item.dump()
Perfect! It work! Thank you 😊
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest