Page 1 of 1

Notification time overcoming Watt

Posted: Saturday 16 May 2020 20:03
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:

Re: Notification time overcoming Watt

Posted: Sunday 17 May 2020 1:44
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 ?

Re: Notification time overcoming Watt

Posted: Sunday 17 May 2020 13:23
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 1635 times

Re: Notification time overcoming Watt

Posted: Sunday 17 May 2020 17:44
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 1627 times

Re: Notification time overcoming Watt

Posted: Sunday 17 May 2020 18:40
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"

Re: Notification time overcoming Watt  [Solved]

Posted: Sunday 17 May 2020 19:30
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
}

Re: Notification time overcoming Watt

Posted: Sunday 17 May 2020 23:10
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

Re: Notification time overcoming Watt

Posted: Monday 18 May 2020 0:41
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 

Re: Notification time overcoming Watt

Posted: Monday 18 May 2020 1:57
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()

Re: Notification time overcoming Watt

Posted: Monday 18 May 2020 9:27
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 😊