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

Log time in virtual device?


PGL

Question

Hello.

I have a simple VD to change icons if my wife and i is precent/absent from home. 

 

local thismodule = fibaro:getSelfId(); 
local status = fibaro:getGlobal("p_home")
-- fibaro:debug(thismodule);
if
    status == "0"
then 
    fibaro:call(thismodule, "setProperty", "currentIcon", 1003)
end

if
    status == "1"
then 
    fibaro:call(thismodule, "setProperty", "currentIcon", 1004)
end

fibaro:sleep(1000);

 

Is there any way to make, so that the virtual Device can show what time we arrived/left the home?

 

Ex: P Arrived at home 15:55 so it only shows the latest arrival or departure date?

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Hi @PGL ,

 

just replace this line of code:

Please login or register to see this code.

with this code:

Please login or register to see this code.

Now local variable ch_time contain time in format "00:00" when global variable was changed or actually when you left or arrive home.

 

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • On 11/10/2018 at 4:41 PM, Sankotronic said:

    Hi @PGL ,

     

    just replace this line of code:

    Please login or register to see this code.

    with this code:

    Please login or register to see this code.

     Now local variable ch_time contain time in format "00:00" when global variable was changed or actually when you left or arrive home.

     

     

     

    Hi.  Thanks for your help.

     

    Is it possible to make a label in the VD with:

    red text; Left: (Time)

    Green text; Arrived: (Time)

    Link to comment
    Share on other sites

    • 0
    1 hour ago, PGL said:

     

    Hi.  Thanks for your help.

     

    Is it possible to make a label in the VD with:

    red text; Left: (Time)

    Green text; Arrived: (Time)

     

    Hi @PGL ,

     

    Yes it is possible, but label text will be in red or green color only in browser while on mobile apps will have no color but besides time you will see also color formatting text making it unreadable. I suggest to use emoji to make it visually different for leaving or arriving home.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Great thank you. i will use the icon, how do i make a label in the VD stating left/-arrived time?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 10 hours ago, Sankotronic said:

     

    Hi @PGL ,

     

    Yes it is possible, but label text will be in red or green color only in browser while on mobile apps will have no color but besides time you will see also color formatting text making it unreadable. I suggest to use emoji to make it visually different for leaving or arriving home.

     

    is it something like; ?     fibaro:call(thismodule, "setProperty", "ui.Label1.value", tostring(fibaro:getGlobalValue(ch_time))); - i really cant get it working :-)

    Link to comment
    Share on other sites

    • 0
    3 hours ago, PGL said:

     

    is it something like; ?     fibaro:call(thismodule, "setProperty", "ui.Label1.value", tostring(fibaro:getGlobalValue(ch_time))); - i really cant get it working :-)

     

    Hi @PGL ,

    It goes like this:

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 8 hours ago, Sankotronic said:

     

    Hi @PGL ,

    It goes like this:

    Please login or register to see this code.

     

     

    Perfect, thank you. Working :-)


    Is there any way to add the tekst, left or arrived to the label like;

     

     

    local thismodule = fibaro:getSelfId(); 
    local status, ch_status = fibaro:getGlobal("p_home")
    local ch_time = os.date("%H:%M",ch_status)

    -- fibaro:debug(thismodule);
    if
        status == "0"
    then 
        fibaro:call(thismodule, "setProperty", "currentIcon", 1003)
      fibaro:call(thismodule, "setProperty", "ui.Label1.value", (LEFT)  ch_time)

    end

    if
        status == "1"
    then 
        fibaro:call(thismodule, "setProperty", "currentIcon", 1004)
      fibaro:call(thismodule, "setProperty", "ui.Label1.value", (ARRIVED) ch_time)

    end


    fibaro:sleep(1000);

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 12 minutes ago, Sankotronic said:

    Hi @PGL ,

     

    try following code:

    Please login or register to see this code.

    Enjoy coding :-)

     

    Perfekt. Thank you so much :-)

    Link to comment
    Share on other sites

    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...