Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Question

Posted

Hi,

I am trying to get a VD ui.lblStatus value to trigger the following scene but it seems to be stopped by the blank lblStatus values prior to receiving the ON or OFF values. Everything else works fine..

Does anyone know why this happens and how to work around it?

 

--[[
%% properties
46 ui.lblStatus.value
%% events
%% globals
--]]

PushNotificationID = fibaro:getGlobal('PushNotificationID')
local device = 46
local status = fibaro:getValue(device, "ui.lblStatus.value")
print (status)

if status == "OFF"
    then
        api.put('/scenes/133', {iconID=1023})
        fibaro:call(PushNotificationID, "sendDefinedPushNotification", "17");
        fibaro:call(2, "sendDefinedEmailNotification", "17");
    end

if status == "ON"
    then
        api.put('/scenes/133', {iconID=1022})
        fibaro:call(PushNotificationID, "sendDefinedPushNotification", "16");
        fibaro:call(2, "sendDefinedEmailNotification", "16");
    end

if status == "OFFLINE"
    then
        api.put('/scenes/133', {iconID=1034})
    end

 

Please login or register to see this attachment.

4 answers to this question

Recommended Posts

  • 0
Posted

I'm not that great with LUA but I try to help. You have typed the following: 

Please login or register to see this code.

 

But at the

Please login or register to see this code.

You didn't mention print (status)

 

Or use fibaro:debug(" ") and type between the " " what you want to see in the debug windows.

 

I hope this helped for a LUA newbie:lol:

  • 0
Posted

meaby this is what you mean

 

--[[
%% properties
46 ui.lblStatus.value
%% events
%% globals
--]]

PushNotificationID = fibaro:getGlobal('PushNotificationID')
local device = 46
local status = fibaro:getValue(device, "ui.lblStatus.value")
print (status)

if status ~= "" then
    if status == "OFF" then
        api.put('/scenes/133', {iconID=1023})
        fibaro:call(PushNotificationID, "sendDefinedPushNotification", "17");
        fibaro:call(2, "sendDefinedEmailNotification", "17");
    end
    if status == "ON" then
        api.put('/scenes/133', {iconID=1022})
        fibaro:call(PushNotificationID, "sendDefinedPushNotification", "16");
        fibaro:call(2, "sendDefinedEmailNotification", "16");
    end
    if status == "OFFLINE" then
        api.put('/scenes/133', {iconID=1034})
    end
else fibar:abort()
end

  • 0
  • Inquirer
  • Posted

    Hi Kage,

     

    Unfortunately adding " if status ~= "" then " hasn't made hasn't helped . I still get the same response where the if statements don't trigger. Any other ideas?

    • 0
    Posted (edited)

    How about working around this by having the VD set a global var with the same value as the status label and make the scene trigger on that global var?
    Is this doable, can you edit the VD code to set a variable?

    The current trigger could be tripping on every UI refresh and with the insane rate of triggers who knows what kinds of weird behavior might resurface here.
    I'd try to shift to another implementation using different trigger type like a global var I mentioned above or even have the scene called from the VD on every label update.

    BTW, how is the label updated in the VD itself? Could it be pumping in the same value in a loop without any delays?

    Edited by mika

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...