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

Scene not triggering (with hue lamp included)


samuel

Question

This is a scene.. triggering a variable "saying if a light is ON change variable to AWAKE

id 313 is a hue plugin and i want to use this one to trigger a variable, saying house awake, together with many other modules.

It's not triggering to AWAKE. what i am doing wrong?

 

--[[
%% autostart
%% properties
79 value
313 state
%% weather
%% events
%% globals
--]]

if  ( tonumber(fibaro:getValue(79, "value")) > 0  or    -- kitchen tsble
       tostring(fibaro:getValue(313, "state")) == true    -- floor luminaire 2 hue
    )
then
    fibaro:setGlobal("Auto_Sleep_Mode", "AWAKE");
end

 

thanks a lot

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

The topic has been moved from "

Please login or register to see this link.

" to "

Please login or register to see this link.

".

 

Temat został przeniesiony z "

Please login or register to see this link.

" do "

Please login or register to see this link.

".

Link to comment
Share on other sites

  • 0
On 12/14/2016 at 1:50 PM, samuel said:

somebody able to help?

Hi @samuel,

 

You need to change this line of code:

Please login or register to see this code.

to this line:

Please login or register to see this code.

and it should work. Function fibaro:getValue is always returning value in string format so if you want to compare it to numeric value then you MUST use 'tonumber' function and that is first solution. In second number 1 is put between quotes so turned to string value. Just to mention that 'true' is boolean value and can't be compared to string or numeric values and if it is it will be always not true.

 

Also to check what properties you can read from any device, virtual device or plugin open some scene in LUA and on the left side you will then have column Devices list where you can inspect what properties you can get with function fibaro:getValue, and what command you can send to device with fibaro:call, see pic bellow:

 

 

Enjoy coding! :-)

Edited by Sankotronic
Attachment quota filled up / deleting older stuff sorry :-(
Link to comment
Share on other sites

  • 0
  • Inquirer
  • Ok thanks, iI took those properties from the hue lamp the way you did in your photo. :) it was only a matter of implementing the sentence. what I didn't fully understand.

     

    Is this also correct?

    So when hue lamp = OFF then:

     

    (tonumber(fibaro:getValue(313, "off")) == 0)

    or

    (fibaro:getValue(313, "off")) == "0"

     

    What about the trigger part of the scene, is that correct?

    --[[
    %% autostart
    %% properties
    79 value
    313 state
    %% weather
    %% events
    %% globals
    --]]

     

    313 state or 313 value, or different than this?

     

     

    Edited by samuel
    Link to comment
    Share on other sites

    • 0
    53 minutes ago, samuel said:

    Ok thanks, iI took those properties from the hue lamp the way you did in your photo. :) it was only a matter of implementing the sentence. what I didn't fully understand.

     

    Is this also correct?

    So when hue lamp = OFF then:

     

    (tonumber(fibaro:getValue(313, "off")) == 0)

    or

    fibaro:getValue(313, "off" == "0"

     

    at the trigger part of the scene:

    --[[
    %% autostart
    %% properties
    79 value
    313 state
    %% weather
    %% events
    %% globals
    --]]

     

    313 state or 313 value, or different than this?

     

     

    I don't know from where you take property "off" because I don't have it on my HUE plugins list of properties. But anyway if you want scene to be triggered by state of the HUE lamp then you can make this in header:

    Please login or register to see this code.

    You can remove %% autostart because this scene doesn't need to be started that way. Now scene will be triggered by value of the" kitchen tsble" what ever that is and every time when HUE lamp change state from On to Off and from Off to On! Your scene then should look something like this:

    Please login or register to see this code.

    Problem with this scene is that you will wake up house every time when this HUE lamp is turned on even in the middle of the night if you turn it On, so this scene should have some more checks to really give you what you want.

     

    My advice to you is to avoid using actors (lamps, plugs, switches, etc.) as triggers if possible and use sensors to trigger wanted actions. For time based actions for time of day, week, month and year you can use my scene that can be found here:

    First install "Sunrise & Sunset" virtual device and then scene and you will have a good base to expand your home automation system.

    For house state sleep and awake state we can discuss first what and how you really want that to function.

     

    For example, I have one scene called "Good morning" which takes care of changing value of the global variable SleepStatus to awake, turning on some lights, starting music, making coffee and speaking good morning greeting together with weather forecast and now even turns On Christmas lights. This scene is triggered by Alarm clock VD made by jompa68 or if alarm clock is turned off then we wake up our hose with Fibaro swipe that we have in our bedroom.

     

    For putting our house to sleep I have scene called "Good night" and it is always triggered manually either by Fibaro swipe in our bedroom or switch on the dimmer of our main bedroom light. This is because we go to sleep always at different times and we don't want that our hose dictate us when to go to bed. This scene first checks selected doors and windows if are closed. What doors and windows will be checked is determined automatically by season state and temperature outside our house. If any found open it tell us on Sonos speaker in our bedroom and waits with sleep state until we close all doors and windows. If everything found properly closed then switches of all lighting, lowers all blinds, turns off music and TV if left on, turns off Christmas lights and other selected devices, arms selected sensors and then on Speaker tell us if coffee machine is ready for tomorrow to make coffee, alarm clock setting, weather forecast for tomorrow and wishes us good night. Nice! :-) 

     

    I don't use status of our lights to change home sleep status because our lights in the house and outside are completely automated and they always turn on if there is not enough light when we enterthe room with brightness level that is adjusted to the time of day or special conditions. That switch on dimmer of our light in our bedroom that I mentioned before is not the one that turns light on/off but the other one that trigger scene. We don't use any switches for lighting in our house any more.

     

    I'm sorry if I bothered you with all this story!

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • actually, i am using it to detect which lights stayed on during the night and at a certain time it will switch off these lamps and if forgotten I will receive a notification in the morning that I had forgotten to switch off light during the evening, before going to bed.

    a scene for awake

    a scene for sleeping, 

    a scene for forgot lights

    a scene for action if forgotten

    i know i looks complicated, and properly it can be done easier.

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Is this correct for the sleeping scene?

    see below:

     

       
      %% properties
      79 value
      313 off
      %% weather
      %% events
      %% globals
      --]]
       
       
       
      if  ( tonumber(fibaro:getValue(79, "value")) == 0  and    -- kitchen tsble
             tostring(fibaro:getValue(313, "off")) == "0"    -- floor luminaire 2 hue
          )
      then
          fibaro:setGlobal("Auto_Sleep_Mode", "SLEEPING");
      end

     

     

    Link to comment
    Share on other sites

    • 0
    2 hours ago, samuel said:

    Is this correct for the sleeping scene?

    see below:

     

       
      %% properties
      79 value
      313 off
      %% weather
      %% events
      %% globals
      --]]
       
       
       
      if  ( tonumber(fibaro:getValue(79, "value")) == 0  and    -- kitchen tsble
             tostring(fibaro:getValue(313, "off")) == "0"    -- floor luminaire 2 hue
          )
      then
          fibaro:setGlobal("Auto_Sleep_Mode", "SLEEPING");
      end

     

     

     

    Nope, on my HC2 that will definitely not work. Did you test it?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • i got it: :-)

     

    awake scene:     (tostring(fibaro:getValue(313, "on")) == "1") 

    sleeping scene:  (tostring(fibaro:getValue(313, "on")) == "0")

     

    at the properties:

    313 on

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