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

Posted
14 hours ago, jgab said:

 

Ok, to be clear. It's only the code that respond to a PING with a PONG that is built-in to the ER framework currently (that's a 1-liner)

The logic to ping scenes and restart them is not built-in. Then you have to add code like the one from Oct.25.

 

here is my WatchDog scene:

Please login or register to see this code.

and in every other ER scene id={222,227,228,217,192,226} I have:

Please login or register to see this code.

Interesting is that when I use only PING a PONG in WatchDog scene and in other scene I don't have anything because I want to use your build in one - it doesn't work.

 

Any idea where could be problem?

 

 

  • Topic Author
  • Posted (edited)
    45 minutes ago, petrkl12 said:

    Interesting is that when I use only PING a PONG in WatchDog scene and in other scene I don't have anything because I want to use your build in one - it doesn't work.

     

    Any idea where could be problem?

     

     

     

    Very strange - it's the same logic just different names of the messages.

    However,  @jompa68 seems to have made it work (again) using v1.10.

     

    In your scene you disable the scenes and then start them with with some intervals. Wonder if that creates some problems...

    Please login or register to see this code.

    You could start pinging after you start them up

    Please login or register to see this code.

     

    Btw, you can define the local vars in the loop to have access to them in the script - cleaner than to concatenate strings.

    Edited by jgab
    Posted

    ok thanks

    I will have to test version 1.10 ...

     

     

     

  • Topic Author
  • Posted

    New  version 1.11 pushed. EventRunner.lua and EventRunnerDebug.lua.

     

    - Multiple Hue hubs supported.  The setup looks like this now

    Please login or register to see this code.

    If there is only one Hue bridge/hub the hub name part of device names can be left out and defaults to that hub name.

    Ex. if we have a hub with name "Hue", Hue.define("My light","mylight",88) is the same as Hue.define("Hue:My light","mylight",88)

    Disclaimer, I only have 1 Hue hub myself so there could be bugs...

    • Thanks 1
  • Topic Author
  • Posted (edited)

    A small addition to the Hue support.

    New firmware for Hue lights (Dec 8) support "Power-on behaviour". From the app one can choose default (standard bright) or power loss recovery, that is the value the lamp had the last time (before power off).

    However, there is also a customs settings that is not selectable by the app but can be set via the API.

    The advantage is that we then can set whatever values a lamp should start with when it is powered on - and we can do it even if the lamp is off!

    So, in the morning or in the night you can set the lamp to dimmed values and it will start to those values when powered on(!)

    Example:

    Please login or register to see this code.

    ...and the lamp will startup with a red color...yay!

    If the argument to <id>:value is a table with a 'startup' key it is sent to the light as ' /config/startup/<table>', so whatever is supported as startup parameters will work.

    If the id is a Hue group, I will call the config on all lights in the group.

    The custom setting will show up in the Power-on behaviour tab in the app for the lights.

    Google "hue power-on customsettings" to find more info...

     

    This should work

    Please login or register to see this code.

     

    Addition: If you flick the switch on a lamp twice within ~20s, it will always revert to "full light". It seems to be a security things so bad defaults wouldn't hinder lamps to light up a room in an emergency case, like fire.

    Edited by jgab
    • Thanks 1
  • Topic Author
  • Posted (edited)

    A new flow for node-red.

    Please login or register to see this spoiler.

    Please login or register to see this attachment.

     

    The bottom part is the 'node-red-contrib-wemo-emulator ' node that pretends to be a wemo device controllable from Alexa. I tried the other Alexa echo node that emulates Hue but I didn't get it to work. Anyway, it's easy to work as it runs locally and doesn't need any cloud setup.

     

    Setup the node rename it and configure it and you can say "Alexa, turn on Party' or 'Alexa, turn off Party'. It will be sent to the HC2 or the ZBS off line as an EventRunner event.

    The topic is the name of the "device" and the payload is the command. 

    In the response node, if msg.ESceneID=-1 it will send it back to the configured ZBS instance, else it will send to that scene ID on the configured HC2 instance

    Please login or register to see this code.

    and the log running on ZBS is

    Please login or register to see this code.

    ...and it responds very quick.

    Edited by jgab
    Posted

    @jgab thanks for adding support for more hue bridges! 

    I will start testing today with my 4 bridges :)

     

     

    Posted (edited)
    On 1/18/2019 at 8:59 AM, jgab said:

    If there is only one Hue bridge/hub the hub name part of device names can be left out and defaults to that hub name.

    Ex. if we have a hub with name "Hue", Hue.define("My light","mylight",88) is the same as Hue.define("Hue:My light","mylight",88)

    Disclaimer, I only have 1 Hue hub myself so there could be bugs...

    Do i need to change layout of HomeTable now to implement 1.11?

     

    Please login or register to see this code.

    Please login or register to see this code.

     

    Edited by jompa68
  • Topic Author
  • Posted
    1 minute ago, jompa68 said:

    Do i need to change layout of HomeTable now to implement 1.11?

     

    Please login or register to see this code.

     

     

    No, if you only have one Hue hub there is no change.

    But you need to setup the new Hue  credentials/IP

    Please login or register to see this code.

    ...and just give it the name "Hue".

    Hue.define should work as before.

    Posted
    20 hours ago, jgab said:

    In the response node, if msg.ESceneID=-1 it will send it back to the configured ZBS instance, else it will send to that scene ID on the configured HC2 instance

    have trouble to get the command to my HC2, it send only to ZBS. It works with ZBS.

    What have i missed?

  • Topic Author
  • Posted

    You must change ESceneID in the response node. If it's set to -1 the flow in the upper part will send to the ZBS node, otherwise it will send to the HC2 node, and to the scene with ESceneID

    Please login or register to see this attachment.

    If you want different commands to send to different scenes you need to have several response nodes with different ESceneIDs. I don't know if there is a more elegant way to do this...

    Btw, have you configured the HC2 node in the flow below? (actually in the top of the flow canvas)

    If ESceneID is less than 0 the message is switched to the ZBS node, and if it's over 0 it is switched to the HC2 node.

    Please login or register to see this attachment.

    Posted

    Working now, thanks

    Bad that it don't work with Google Home,  i have one GH and one Alexa.

    Posted (edited)

    @jgab

     

    1. this syntax doesn't work:

    Please login or register to see this code.

     

    2. I think toggle command doesn't work for hue groups

     

    3. this also doesn't work

    Please login or register to see this code.

     

     

    Edited by petrkl12
  • Topic Author
  • Posted (edited)
    3 hours ago, petrkl12 said:

    @jgab

     

    1. this syntax doesn't work:

    Please login or register to see this code.

     

    2. I think toggle command doesn't work for hue groups

     

    3. this also doesn't work

    Please login or register to see this code.

     

     

    The second argument to Hue.define is to define a eventscript variable with that name. So that "variable" is only available inside rules.

    So 1. could be 

    Please login or register to see this code.

    or

    Please login or register to see this code.

    ..and 2. has the same problem- There is no Lua variable named 'HueSwitchGarden', only an eventscript variable, available inside rules.

    However, Hue.monitor takes a ID or a "fully qualified Hue name", so this works

    Please login or register to see this code.

    or you can do monitor in a rule

    Please login or register to see this code.

     

    Anyway, so here afterwards, the argument to define an eventscript variable with Hue.define was unnecessary.

    I, and @jompa68, have the eventscript mapping in the HomeTable anyway. If it was Hue.define(<Hue name>,<id>) one could do

    define(<eventscript variable>,Hue,define(<Hue name>,<id>)) if needed.

    So, for the next release I may change Hue.define... simpler is better.

     

     

    Edited by jgab
    Posted

    Thanks for your answers!

     

    I have some other questions/ideas about hue as I want to transfer all my hue rules/scenes to your ER:

     

    1. Is there possibility how to define hue via hue id. I know in this case i will have to say what is light, group, sensor etc.

    Something like:

     

    Please login or register to see this code.

    2. I think toggle command doesn't work for hue groups

     

    3. How to run hue scene for groups - based on scene id, based on scene name? Do you have any examples?

     

    4. How to run hue lights/groups with combination of parameters ie. "on":true,"hue":5996,"sat":254,"bri":127

     

    5. Is it possible to use: 

    Please login or register to see this code.

    6. How to check if deviceID (ie. 30500) belongs to hue in event?

     

    7. Do you have any examples for using Hue motion sensors, light sensors, temperature sensors in ER (all is one physical device) ?

     

    Sorry for many questions but I don't have any other source :)

     

    Thanks

     

    Posted (edited)

    Just idea for hue support:

     

    Current solution for Hue.monitor is OK for less number of monitored devices.

    I think if there will bigger number of devices where I will need to check sensors, lights,... there could be better to use following pattern: 

     

    1. read info about all sensors, lights, groups via ie. /api/../sensors every xx miliseconds (define period)

    2. compare if something was change from previous reading

    3. if true in point 2 then to check define hue devices in ER if something was change in specific/define device

     

    I think it could be more efficient. What do you think?

    I think there could be both option - for a few hue devices current solution, for more devices new one

     

    Edited by petrkl12
  • Topic Author
  • Posted (edited)
    1 hour ago, petrkl12 said:

    Thanks for your answers!

     

    I have some other questions/ideas about hue as I want to transfer all my hue rules/scenes to your ER:

     

    1. Is there possibility how to define hue via hue id. I know in this case i will have to say what is light, group, sensor etc.

    Something like:

     

    Please login or register to see this code.

    2. I think toggle command doesn't work for hue groups

     

    3. How to run hue scene for groups - based on scene id, based on scene name? Do you have any examples?

     

    4. How to run hue lights/groups with combination of parameters ie. "on":true,"hue":5996,"sat":254,"bri":127

     

    5. Is it possible to use: 

    Please login or register to see this code.

    6. How to check if deviceID (ie. 30500) belongs to hue in event?

     

    7. Do you have any examples for using Hue motion sensors, light sensors, temperature sensors in ER (all is one physical device) ?

     

    Sorry for many questions but I don't have any other source :)

     

    Thanks

     

     

    1. I pushed a new version with a new function Hue.hueName(<Hue descr>) so you can do 

    Please login or register to see this code.

    Hue.hueName gets the "fully qualified name" from the Hub name and Hue id with that specific syntax (SensorID, GroupID, LightID)

     

    2. That was a bug. Fixed in the pushed version.

     

    3. By name.

    Please login or register to see this code.

    'Bright' is a scene defined on the hub where the group is

     

    4. :value again

    Please login or register to see this code.

    5. No, loop over the table and call monitor.

     

    6. To check if an id is a Hue id do

    Please login or register to see this code.

    7. The only thing I have is a button switch... but let's see if we can get it to work,

    Hue.monitor takes a third argument that is a filter. The default is {buttonevent=true, on=true}

    When the state changes for a Hue device, for every property I check filter[prop]==true ? and if so, I do a

    Please login or register to see this code.

    That means that if a device changes the on property from true to false or the other way, I will post the event

    Please login or register to see this code.

    _hue is just a marker that it comes from a Hue device and _sh that the post shouldn't be logged.

    On the HC2 there is no trigger with properyName=='on', so we want to rewrite it to a standard 'value' trigger and we do that with the rule

    Please login or register to see this code.

    We could do the same with button events but there is no code for that at the moment. (probably rewrite it to a centralSceneEvent)

    Anyway, I don't know what the names of the properties are for your device, but assume that they are 'motion','temp', and 'lux'

    Please login or register to see this code.

    would make it start to post events when those properties change values.

    Ex.

    Please login or register to see this code.

    ...and you can add an Event handler like above to rewrite the event to look more like a fibaro temp sensor if you want.

    There is problem because fibaro:getValue(id,'value') is kind of hardcoded for Hue lights currently. fibaro:getValue(id,'temp') works though

     

    14 minutes ago, petrkl12 said:

    Just idea for hue support:

     

    Current solution for Hue.monitor is OK for less number of monitored devices.

    I think if there will bigger number of devices where I will need to check sensors, lights,... there could be better to use following pattern: 

     

    1. read info about all sensors, lights, groups via ie. /api/../sensors every xx miliseconds (define period)

    2. compare if something was change from previous reading

    3. if true in point 2 then to check define hue devices in ER if something was change in specific/define device

     

    I think it could be more efficient. What do you think?

    I think there could be both option - for a few hue devices current solution, for more devices new one

     

     

    Yes, that's a possibility - how many sensors do you have?

    One can get the full state of every device on a hub (that's what I do at startup), but Philips recommend in their development guidelines to not do that more often than every 10s for synchronisation tasks. Doing three calls (lights, sensors,groups) for every hub every 500ms will generate some traffic... I still wish that they fixed a call-back mechanism.

    Edited by jgab
    Posted

    Thanks

    My sensors in 4 bridges

    25x Hue dimmers

    11x Hue motion sensors (motion, light and temperature sensors inside)

     

    Motion sensors:

    Please login or register to see this code.

    Light sensor:

    Please login or register to see this code.

    Temperature sensor:

    Please login or register to see this code.

     

  • Topic Author
  • Posted (edited)

    So,

    Please login or register to see this code.

    would start to post events for those devices.

    Edited by jgab
    Posted

    OK thanks a lot for your support !

    38 minutes ago, jgab said:

     

    3. By name.

    Please login or register to see this code.

    'Bright' is a scene defined on the hub where the group is

     

     

    but there are more same names for scenes in one hub as you can see:

    Please login or register to see this code.

     

    44 minutes ago, jgab said:

     

    One can get the full state of every device on a hub (that's what I do at startup), but Philips recommend in their development guidelines to not do that more often than every 10s for synchronisation tasks. Doing three calls (lights, sensors,groups) for every hub every 500ms will generate some traffic... I still wish that they fixed a call-back mechanism.

     I'm wating for 3 years ... but still nothing btw. based on developers pages this is most wanted functionality ...

     

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