afterMin() problem

Moderator: leecollings

Post Reply
User avatar
pgielen
Posts: 91
Joined: Monday 18 February 2019 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Boxmeer
Contact:

afterMin() problem

Post by pgielen »

I'm having problems using the afterMin function in dzvents. For some reason, the following does not work:

dz.notify('Washingmachine', 'The laundry is done', PRIORITY_LOW, dz.NSS_PUSHOVER).afterMin(15)

The notification is sent immediately and the log file says: 'attempt to index a nil value'. What could be the problem?
https://robothuis.nl, RPi4B, RFXCOM XL, Aeotec Z-Stick, ESP Easy, Weatherstation, several switches and sensors, Ikea Trädfri, Philips Hue, Foscam, Reolink, Lyric T6, Ring
User avatar
felix63
Posts: 244
Joined: Monday 07 December 2015 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Gouda
Contact:

Re: afterMin() problem

Post by felix63 »

According to the DzVents documentation notify doesn't support the afterMin option.
Spoiler: show
notify(subject, message, priority, sound, extra, subsystem): Function. Send a notification (like Prowl). Priority can be like domoticz.PRIORITY_LOW, PRIORITY_MODERATE, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_EMERGENCY. For sound see the SOUND constants below. subsystem can be a table containing one or more notification subsystems. See domoticz.NSS_xxx types.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: afterMin() problem

Post by waaren »

pgielen wrote: Saturday 30 March 2019 22:59 I'm having problems using the afterMin function in dzvents. For some reason, the following does not work:

dz.notify('Washingmachine', 'The laundry is done', PRIORITY_LOW, dz.NSS_PUSHOVER).afterMin(15)

The notification is sent immediately and the log file says: 'attempt to index a nil value'. What could be the problem?
domoticz does not natively support delayed notifications. Please see attached for a workaround.

Code: Select all

--
-- Is the laundry ready?
--
 local webResponse = 'delayedNotificationForWashingMachineReady'
 
 return  {   on =    {  
                        devices    = { 'Floodsensor trillingen' },
                        httpResponses = { webResponse },
                    },

    data = { vibrationStateUpdates = { history = true, maxMinutes = 5 } },

    execute = function(dz, item)
    
        local function delayedNotification(delay)
            url = dz.settings['Domoticz url'] .. '/json.htm?type=command&param=addlogmessage&message=' .. webResponse
            dz.openURL({
                                url = url,
                                method = 'GET',
                                callback = webResponse
                        }).afterMin(delay)
        end
        
        if item.isHTTPResponse then 
            dz.notify('Washingmachine', 'The laundry is done', PRIORITY_LOW,nil,nil, dz.NSS_PUSHOVER) -- syntax is notify(subject, message, priority, sound, extra, subsystem)
        else
            dz.data.vibrationStateUpdates.add(item.state)
            local vibcnt = dz.data.vibrationStateUpdates.size
            print('Status changes in the last 5 minutes: '.. vibcnt)
            if (vibcnt > 15) then
                print('Spin drying') 
                delayedNotification(15)
                dz.data.vibrationStateUpdates.reset() -- remove entries in persistent history
            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
pgielen
Posts: 91
Joined: Monday 18 February 2019 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Boxmeer
Contact:

Re: afterMin() problem

Post by pgielen »

Thanks, I'll try this.
https://robothuis.nl, RPi4B, RFXCOM XL, Aeotec Z-Stick, ESP Easy, Weatherstation, several switches and sensors, Ikea Trädfri, Philips Hue, Foscam, Reolink, Lyric T6, Ring
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest