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

Alarm clock panel using virtual device


Question

Posted

After the implementation of the usefull scheduler provided from Robmac, I defined an alarm panel (see the attachment) in order to update the timing set in a global variable instead of changing it always through the code.

First of all you have to define a multiple global variable type HH:MM

Then you can define a virtual device with labels and buttons.

In the main loop of the virtual device you can set the code to show in the label.

e.g. in my case

---------------MAIN LOOP CODE-----------

local newora = fibaro:getGlobalValue("Sveglia")

H = string.sub(newora, 1, 2)

M = string.sub(newora, 4, 5)

if tonumber(H) < 23

then

H = tonumber(H) + 1

else H = 0

end

if string.len(H) < 2

then H = string.format("%s%s", '0', H)

else

end

newora = string.format("%s:%s", H, M)

fibaro:setGlobal("Sveglia", newora);

---------------END MAIN LOOP CODE-----------

and the buttons to change the hours and minutes (HH:MM)

e.g. in my case the wakeup time to start a scene using the Robmac scheduler

----------BUTTON 1 H[+]--------------------------------------

local newora = fibaro:getGlobalValue("Sveglia")

H = string.sub(newora, 1, 2)

M = string.sub(newora, 4, 5)

if tonumber(H) < 23

then

H = tonumber(H) + 1

else H = 0

end

if string.len(H) < 2

then H = string.format("%s%s", '0', H)

else

end

newora = string.format("%s:%s", H, M)

fibaro:setGlobal("Sveglia", newora);

----------END BUTTON 1 H[+]--------------------------------------

Consequently the other buttons are simple to retrieve.

------------------[H-]---------------------------

local newora = fibaro:getGlobalValue("Sveglia")

H = string.sub(newora, 1, 2)

M = string.sub(newora, 4, 5)

if tonumber(H) > 0

then

H = tonumber(H) - 1

else H = 23

end

if string.len(H) < 2

then H = string.format("%s%s", '0', H)

else

end

newora = string.format("%s:%s", H, M)

fibaro:setGlobal("Sveglia", newora);

------------------[H-] END---------------------------

------------------[M+]---------------------------

local newora = fibaro:getGlobalValue("Sveglia")

H = string.sub(newora, 1, 2)

M = string.sub(newora, 4, 5)

if tonumber(M) < 50

then

M = tonumber(M) + 10

else M = 0

end

if string.len(M) < 2

then M = string.format("%s%s", '0', M)

else

end

newora = string.format("%s:%s", H, M)

fibaro:setGlobal("Sveglia", newora);

------------------[M+] END---------------------------

------------------[M-]---------------------------

local newora = fibaro:getGlobalValue("Sveglia")

H = string.sub(newora, 1, 2)

M = string.sub(newora, 4, 5)

if tonumber(M) > 0

then

M = tonumber(M) - 10

else M = 50

end

if string.len(M) < 2

then M = string.format("%s%s", '0', M)

else

end

newora = string.format("%s:%s", H, M)

fibaro:setGlobal("Sveglia", newora);

------------------[M-] END---------------------------

Then to submit to the Robmac scheduler immediately the defined time (you can force but if I well understood the scheduler refreshes every 12 hours automatically) the last button "UPDATE".

------------Button UPDATE------------

fibaro:killScenes()

fibaro:startScene()

------------END Button UPDATE------------

Regards

Marco

PS: Due to a technical Fibaro's website problem I am not currently able to upload the picture sample above mentioned.

I will post it later as soon as the "Technical maintenance warning will disappear".

[ Added: 2013-09-09, 22:08 ]

here is the image

Please login or register to see this attachment.

4 answers to this question

Recommended Posts

  • 0
Posted

Looks good.

BTW the scheduler only updates the solar based events every 12 hrs.

Sunset early afternoon and sunrise early morning. By default 12:05 and 00:05.

If you live at extreme latitudes I guess you may want to configure these.

Please login or register to see this code.

All events with fixed times are only loaded at start up so to save alarm timer you will need to restart the schedule.

  • 0
  • Inquirer
  • Posted

    I am currently still doing tests and further adjustments, so thanks for the clarification Robmac.

    Following the same logic I am currently developing a temperature control, I am not happy with the Horstman approx (+- 1.0 C°), so I am going to start with something like this.

    My intention is to define also an hysteresis parameter with a further label/buttons.

    The label on top is the average of current temperature retrieved from the sensors.

    The label below should be the setpoint.

    So now I am going to manage also +- 0.1 C° approximation.

    Regards

    Marco

    Please login or register to see this attachment.

    • 0
    Posted

    Hi,

    Can you share your virtual device? how you show time in the first label?

    thx

    • 0
    Posted

    +1, please share the VD

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