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


Recommended Posts

  • Topic Author
  • Posted

    The test for 'equality' is '==', a single '=' is for assignment.

    Please login or register to see this code.

    Which is the same as writing

     

    Please login or register to see this code.

    because the variable is true when we want something too be done.

    Important that you have declared 

    Util.defTriggerVar('GAR_L_State',false)

    before the rules are declared in main()

     

    Please login or register to see this code.

     

    What I'm missing here is some rule to set GAR_L_State to false when the light is automatically turned on.

     

    Unless you use it elsewhere you don't strictly need the GAR_L_State variable?

    Please login or register to see this code.

    Here we have a non-trigger variable, GAR_L_Manual to remember if the light was turned on manual and in that case not turn ot off, after 8 minutes....

     

    Posted

    Hi Jan,

     

    Could i turn off a rule for like a time?

    like if i manually turn off the light in a room the light should not turn on by the motion rule?

     

    Many thanks

  • Topic Author
  • Posted
    24 minutes ago, Qwerty1979 said:

    Hi Jan,

     

    Could i turn off a rule for like a time?

    like if i manually turn off the light in a room the light should not turn on by the motion rule?

     

    Many thanks

    Please login or register to see this code.

     

    I guess after some time after the light was turned on it's still ok to turn own the light with the sensor? 

    Here I reset the 'manual' flag after 30min being true...

     

    Posted
    On 2/4/2022 at 1:09 PM, Sjakie said:

    @

    Please login or register to see this link.

     , asbypass for your Denon plug it in a wall plug.

    If power higher than x >>on and lower than x >>off

    //Sjakie

     

     

    @Sjakie yes I also was thinking about this workaround,but rather try it first through the software before buying another piece of hardware.

    when I don't get it to work I will try your idea

    Posted

    @Joel, I see the following error:

    On the left side if you use as trigger:

    Please login or register to see this code.


     

    Posted

    @edwin023,

    okay

    --I dont know how you enable Denon

    --I dont know if Denon can give by API command back, I doubt I thought its one way traffic

    You have a qa who switch Denon on

    ad another rule:

    same trigger as Denon:on but extend trigger with & sunset..sunrise

    It will only switch Denon:on if he is already on but I dont think you will notice it.

    I hope it solves your problem.

    //Sjakie

    Posted
    On 2/4/2022 at 8:26 AM, jgab said:

     

    Something like below. (I haven't been able to test run the rules so there could still be some issues and spelling mistakes)

    I think you should use the HT to define names for your device - like I did for woonkamer.motion

    Then you can use their names in the rules instead of the device number. Device numbers may change if you need to reinstall a device. Then you only need to update the HT and not all the rules.

    I put your changes that you suggested, but I got an error but the light turns on:

    in Rule:8[woonkamer.motion:breached & woonkamer.hue:isOff & woonkamer.lichtinval:lux < 25 =>>...]: ./include/EventRunner.lua:1953: ./include/EventRunner.lua:1358: attempt to compare number with nil

    On 2/4/2022 at 8:26 AM, jgab said:

     

    Now the L log command separates user  logs from ER logs. Set USERTAG back to QUICKAPP if you want them in the same log.

     

    Are your Hue lamps Philips only - or you use some 3rd part signee lamps?

     

     

    Iam still trying to implement the log options think I don't understand so iam gone read some more on this subject.

    I only have Philips Hue lamps, as far as I know Zigbee is still not supported yet by hc3.

    when I define the 207 in the following rule it doesn't work (207=woonkamer.schakel)

    rule("207:scene ==  20 => woonkamer.hue:off")--Handmatig Hue lampen uit.

     

    I will post the changed code down below.

     

    local HT = { 

      keyfob = 26, 

      woonkamer = { motion = 229 ,lichtinval = 231 , temp = 230 , spotjes = 208 , hue = 180,203,175,291 , schakel = 207 , reciever = 290 , kodi = 194},

      gang = { motion = 218 , lamp = 38 , temp = 219 , lichtinval = 220 },

      keuken = { motion = 235 , lamp = 78 , temp = 236 , lichtinval = 237 }

    }

      

    Util.defvars(HT)

    Util.reverseMapDef(HT)


     

    local USERTAG = "Eventrunner" -- "QUICKAPP"

    function L(c,f,...)

      return string.format("#T:%s%s##C:%s#%s",USERTAG,quickApp.id,c,string.format(f,...))

    end

    rule("log(L('green','My ER starting (%s,%s)',E_VERSION,E_FIX))")

     

    --------Daytime-------------------------------------

    rule("log(L('orange','-------------- Regels vaststellen ---------------'))")

    rule("global('DayTime')")

    rule("07:00..12:00-1 => $DayTime='Morning'").start()

    rule("12:00..18:00-1 => $DayTime='Day'").start()

    rule("18:00..23:00-1 => $DayTime='Evening'").start()

    rule("23:00..07:00-1 => $DayTime='Night'").start()

    rule("@@01:00:00 => log('Status woning %s state',$DayTime)")

     

    --------------------Gang tafelamp------------------

     

    rule("gang.motion:breached & gang.lichtinval:lux < 10 => gang.lamp:on ")

    --Tafel lamp aan na beweeg en lux onder 10.Auto uit na 3 min.

    rule("trueFor(00:03,gang.motion:safe) =>  gang.lamp:off")--lamp automatisch uit na 3 min geen beweging.

     

    -----------------------Woonkamer --------------------

    rule("log(L('orange','-------------- Woonkamer ---------------'))")

     

    rule([[woonkamer.motion:breached & woonkamer.hue:isOff & woonkamer.lichtinval:lux < 25 =>>

      || sunset-00:30..19:00 >> woonkamer.spotjes:value=20

      || 19:00..21:00        >> woonkamer.spotjes:value=15

      || 21:00..23:59        >> woonkamer.spotjes:value=10

      || 23:00..sunrise      >> woonkamer.spotjes:value=1

      || true                >> log(L('red','Woonkamer breached outside time intervals'))"]])

      ---Spotjes na beweeg en lux onder de 20 aan.Hue lampen uit.Lumen afhankelijk van de  tijd.

    rule("trueFor(00:20,woonkamer.motion:safe) => woonkamer.spotjes:off")--Spotjes automatisch uit na 20 min geen bweging.

    --rule("208:isOn & 208:manual >= 0 => 208:off")

    --Hndmatig Hue lampen aan en spotjes uit.

    rule("207:scene ==  21  => woonkamer.hue:on & woonkamer.spotjes:off")

    rule("207:scene ==  20 => woonkamer.hue:off")--Handmatig Hue lampen uit.

    rule("woonkamer.reciever:on & sunset-00:30..sunrise+00:30 => woonkamer.hue:value=70")--reciever aan hue lampen aan

    rule("#device{id=woonkamer.kodi,property='state',value='playing'} & sunset-00:30..sunrise+00:30 => woonkamer.hue:value=30; woonkamer.spotjes:off") --Kodi play Hue aan gedimt 30%. Spotjes uit.

    rule("#device{id=woonkamer.kodi,property='state',value='paused'}  & sunset-00:30..sunrise+00:30=> woonkamer.hue:value=50")--Kodi pauze Hue lampen gedimt 50%

    rule("#device{id=woonkamer.kodi,property='state',value='stopped'} & sunset-00:30..sunrise+00:30 => woonkamer.hue:value=70")--Kodi stop hue lampen gedimt 70%.

     

    ---------------------Keuken lamp-------------------

    rule("log(L('skyblue','-------------- Keuken ---------------'))")

     

    Util.defTriggerVar('time',3*60) -- 3min

    rule([[keuken.motion:breached &  keuken.lichtinval:lux < 20 => 

      || sunset-00:30..19:00 >> keuken.lamp:value=20 

      || 19:00..21:00        >> keuken.lamp:value=15 

      || 21:00..23:59        >> keuken.lamp:value=10 

      || 23:00..sunrise      >> keuken.lamp:value=5]])                --Lamp na beweeg en lux onder de 20 aan.Lumen afhankelijk van de  tijd.

    rule("trueFor(time,keuken.motion:safe) =>  keuken.lamp:off; time=00:03:00")-- lamp automatisch uit na 3 min geen beweging.


     

    rule("log(L('orange','-------------- Alle regels vastgesteld---------------'))")

     

    Posted
    4 hours ago, Sjakie said:

    @edwin023,

    okay

    --I dont know how you enable Denon

    --I dont know if Denon can give by API command back, I doubt I thought its one way traffic

    You have a qa who switch Denon on

    ad another rule:

    same trigger as Denon:on but extend trigger with & sunset..sunrise

    It will only switch Denon:on if he is already on but I dont think you will notice it.

    I hope it solves your problem.

    //Sjakie

    I control my tv and connected it to my Denon receiver trough hdmi,when I turn on my tv it also turns on my Denon receiver.

    I could not get the qa to work with my Samsung tv so I wanted to try the qa for my Denon receiver to turn on some light when I turn on my tv/reciever.

    using the qa for de Denon I can only mute/unmute and have volume control but I cannot turn on/off the Denon for some reason.

    But I think you are right and the qa only sends commands to the receiver but doesn't send a commant back.

    So I think I have to do your suggestion to make it work.

  • Topic Author
  • Posted
    2 hours ago, edwink023 said:

    I put your changes that you suggested, but I got an error but the light turns on:

    in Rule:8[woonkamer.motion:breached & woonkamer.hue:isOff & woonkamer.lichtinval:lux < 25 =>>...]: ./include/EventRunner.lua:1953: ./include/EventRunner.lua:1358: attempt to compare number with nil

    Iam still trying to implement the log options think I don't understand so iam gone read some more on this subject.

    I only have Philips Hue lamps, as far as I know Zigbee is still not supported yet by hc3.

    when I define the 207 in the following rule it doesn't work (207=woonkamer.schakel)

    rule("207:scene ==  20 => woonkamer.hue:off")--Handmatig Hue lampen uit.

     

    I will post the changed code down below.

     

    local HT = { 

      keyfob = 26, 

      woonkamer = { motion = 229 ,lichtinval = 231 , temp = 230 , spotjes = 208 , hue = 180,203,175,291 , schakel = 207 , reciever = 290 , kodi = 194},

      gang = { motion = 218 , lamp = 38 , temp = 219 , lichtinval = 220 },

      keuken = { motion = 235 , lamp = 78 , temp = 236 , lichtinval = 237 }

    }

     

     

    You need to set the hue ids in a table

     woonkamer = { motion = 229 ,lichtinval = 231 , temp = 230 , spotjes = 208 , hue = {180,203,175,291} , schakel = 207

    Posted
    40 minutes ago, jgab said:

     

    You need to set the hue ids in a table

     woonkamer = { motion = 229 ,lichtinval = 231 , temp = 230 , spotjes = 208 , hue = {180,203,175,291} , schakel = 207

    Thank you for the quick reply.

    Iam gonne dive into the colored debug lines and trying to smooth out my code a little bit.

    Posted

    @edwin023, wierd you cant switch on/off

    did you try this, change IP adres in yours:

    Please login or register to see this code.

    If you put it without ("     "); in your internet browser it should work and operates your Denon.

    //Sjakie

    Posted
    22 hours ago, jgab said:

    The test for 'equality' is '==', a single '=' is for assignment.

    Please login or register to see this code.

    Which is the same as writing

     

    Please login or register to see this code.

    because the variable is true when we want something too be done.

    ....

     

     

    I think that's what I was doing wrong.

     

    The way I am working it is that the GAR_L_State is set to false by default, defined in my variables section.

     

    When the door opens, it turns the light on and sets GAR_L_State to "true",  then when the light switch is flicked while the lights are on it sets GAR_L_State to "false" and turns the light off. I'm not sure if there is a better way do to it but I will do some more testing. I can't just rely on the door trigger because sometimes I am in there while the door is shut but still want the lights on.

    Posted
    3 hours ago, Sjakie said:

    @edwin023, wierd you cant switch on/off

    did you try this, change IP adres in yours:

    Please login or register to see this code.

    If you put it without ("     "); in your internet browser it should work and operates your Denon.

    //Sjakie

    @Sjakie after a late night search i found a Denon Qa that works,i can turn on/off , mute/unmute and change input.

    So now i have to figure out if i can use it to trigger the lights in ER.

    Thank you for the links, i wil check them out this evening.

  • Topic Author
  • Posted (edited)
    6 minutes ago, edwink023 said:

    @Sjakie after a late night search i found a Denon Qa that works,i can turn on/off , mute/unmute and change input.

    So now i have to figure out if i can use it to trigger the lights in ER.

    Thank you for the links, i wil check them out this evening.

    If you note the deviceID of the Denon QA, ex 567, you can add this rule

    Please login or register to see this code.

    and make a note on what events you get when you start stop the Denon and other  operations.

    These events you can then use to write ER rules to trigger actions like turning on/off lights

    Edited by jgab
    Posted (edited)
    9 hours ago, jgab said:

    If you note the deviceID of the Denon QA, ex 567, you can add this rule

    Please login or register to see this code.

    and make a note on what events you get when you start stop the Denon and other  operations.

    These events you can then use to write ER rules to trigger actions like turning on/off lights

    @Sjakie @jgab

    Gentleman thank you for you support, I got I working.

    Big thumbs up.

     

    Can I use the log rule that jgab posted above also with other qa?

    iam trying to figure out how to get an Plex qa working.

    With this QA I get the name of the movie and the duration, but no play/pauze/stop status.

    It gets its info from a http link using GET,see code below.

    I think I have to dive into the api of Plex, but I think its an impossible task sinds Plex Support Webhooks( perhaps something I have to learn)

     

    function QuickApp:connectPlex()

     local address = "http://"..self.ip..":"..self.port.."/status/sessions"

    self.http:request(address, {

            options = {

                headers = {

                    ["X-Plex-Token"] = "......",

                    ["X-Plex-Client-Identifier"] = "...........",

                    ["Accept"] = "application/json",

                },

                method = "GET"

            },

            success = function(response)

     

    if tonumber(plexdata.MediaContainer.size) > 0 then

        metaDataInfo = plexdata.MediaContainer.Metadata[1]

        media = metaDataInfo.librarySectionTitle

        audioCodec = metaDataInfo.Media[1].audioCodec

        duration = self:convertTime(metaDataInfo.duration)

        summary = metaDataInfo.summary

                plexdata = json.decode(response.data)

                --self:debug(response.data)

                self:videoData(plexdata)

                end,

            error = function(err) self:debug("Error: " .. err) end

        }

      )

      end

     

    also found some Webhooks payloads, is there something I can use?

     

    Media starts playing (media.play). An appropriate poster is attached.

    Media playback pauses (media.pause)

    Media playback resumes (media.resume)

    Media playback stops (media.stop)

    Media is viewed (played past the 90% mark) (media.scrobble)

    Media is rated (media.rate). A poster is also attached to this event.

    Edited by edwink023
    Posted

    .

    @jgab i stil get the error, is this created because I manual turn of the light?

     in Rule:8[woonkamer.motion:breached & woonkamer.hue:isOff & woonkamer.lichtinval:lux < 25 =>>...]: ./include/EventRunner.lua:1953: ./include/EventRunner.lua:1358: attempt to compare number with nil

    dwwdwdsdf

  • Topic Author
  • Posted
    12 hours ago, edwink023 said:

    .

    @jgab i stil get the error, is this created because I manual turn of the light?

     in Rule:8[woonkamer.motion:breached & woonkamer.hue:isOff & woonkamer.lichtinval:lux < 25 =>>...]: ./include/EventRunner.lua:1953: ./include/EventRunner.lua:1358: attempt to compare number with nil

    dwwdwdsdf

    Can you post the whole rule? 

    Posted
    4 hours ago, jgab said:

    Can you post the whole rule? 

    rule([[woonkamer.motion:breached & woonkamer.hue:isOff & woonkamer.lichtinval:lux < 25 =>>

      || sunset-00:30..19:00 >> woonkamer.spotjes:value=20

      || 19:01..21:00        >> woonkamer.spotjes:value=15

      || 21:01..23:59        >> woonkamer.spotjes:value=10

      || 23:00..sunrise      >> woonkamer.spotjes:value=1

      || true                >> log(L('red','Woonkamer breached outside time intervals'))"]])

  • Topic Author
  • Posted

    It's an extra '>' char at the end of the first line

    Please login or register to see this code.

     

    Posted

    glad its that simple, i changed it and will see if the error stays away.

    thans you for the quick responds.

    Join the conversation

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

    Guest
    Reply to this topic...

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