using percentage in lua

Moderator: leecollings

Post Reply
tiga
Posts: 156
Joined: Friday 27 May 2016 20:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: nederland
Contact:

using percentage in lua

Post by tiga »

hello all!

i have a "type: general, percentage" device called "wtw filter levensduur (9mnd)" that is logging a filter life usage

i want to send an email when filter is 50% used and 75% used

this is what i got:

Code: Select all

commandArray = {}

if devicechanged['wtw filter levensduur (9mnd)'] then

    waarde     = (tonumber(otherdevices_svalues["wtw filter levensduur (9mnd)"]))
    
    
    if waarde == 50 then
        commandArray[1]={['SendEmail'] = 'wtw filter#wtw filter is 50% vervuild, uitzuigen!#[email protected]' }
    end
    
    if waarde == 75 then
        commandArray[1]={['SendEmail'] = 'wtw filter#wtw filter is 75% vervuild, bestel een nieuwe!#[email protected]' }
    end
    

end

return commandArray
the lua script is running device triggered

but nothing happens if i have 50% or 75%

i think the error must be in this part: waarde = (tonumber(otherdevices_svalues["wtw filter levensduur (9mnd)"])) but i dont know how to fix it

or is this some kind of loop prevention couse the ['wtw filter levensduur (9mnd)'] is updated by another script?????!!!!
HvdW
Posts: 529
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: using percentage in lua

Post by HvdW »

Maybe use the dump() statement for your device to see what values should be used.
Bugs bug me.
User avatar
waltervl
Posts: 5378
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: using percentage in lua

Post by waltervl »

Perhaps you can learn from your own previous topic here https://domoticz.com/forum/viewtopic.ph ... ge#p318704
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests