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


HC3 QuickApps coding - tips and tricks


jgab

Recommended Posts

4 minutes ago, jgab said:

On my machine (Mac/Safari) they behave correct (both in "device list view" and "House overview view"). On the web UI the on/off buttons on devices that are mapped to com.fibaro.philipsHueLight have ugly buttons that don't show state in the UI, only the color ring shifts to greys when it's off. All other lights in the web UI has on/off buttons where the button selected turns blue. And they all work for me. Disclaimer, I don't have any lights of type "Color light' but when I map my "Extended color lights" to the same class they behave well.

 

In the app it's a different story,  it seems like on/off is not synced well for any light - all my lamps start off as ON even though they are off.

 

Ok. I've only tested with Chrome and PC. I'll test with my mac and another browser too. 

Link to comment
Share on other sites

  • Topic Author
  • 2 minutes ago, Freddan67 said:

    Ok. I've only tested with Chrome and PC. I'll test with my mac and another browser too. 

    FYI, Chrome on (my) mac works too..

    Link to comment
    Share on other sites

    8 minutes ago, jgab said:

    FYI, Chrome on (my) mac works too..

    Get the same no matter what I try so there is probably something wrong with me if it works for you

    Link to comment
    Share on other sites

    15 minutes ago, jgab said:

    FYI, Chrome on (my) mac works too..

    I can be something on the track, brightness is set to 0 when I turn on the lamp I change it and the status of the lamp changes. If I turn off the lamp, I need to turn brightness down to 0 again for the status to be changed to off

    Link to comment
    Share on other sites

  • Topic Author
  • 1 minute ago, Freddan67 said:

    I can be something on the track, brightness is set to 0 when I turn on the lamp I change it and the status of the lamp changes. If I turn off the lamp, I need to turn brightness down to 0 again for the status to be changed to off

    These are "Color lights" hue types?

    Link to comment
    Share on other sites

  • Topic Author
  • 1 minute ago, Freddan67 said:

    No just "white"

    Of hue type "Dimmable light" and mapped to 'com.fibaro.multilevelSwitch'? 

    Link to comment
    Share on other sites

    3 minutes ago, jgab said:

    These are "Color lights" hue types?

     

    It seems that whoever it works on looks this way

    Please login or register to see this attachment.

    1 minute ago, jgab said:

    Of hue type "Dimmable light" and mapped to 'com.fibaro.multilevelSwitch'? 

    correct

    3 minutes ago, jgab said:

    Of hue type "Dimmable light" and mapped to 'com.fibaro.multilevelSwitch'? 

    These do not change the status no matter what I do, they are of the "lightstrip" 

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • 3 minutes ago, Freddan67 said:

     

    It seems that whoever it works on looks this way 

    Please login or register to see this attachment.

    For me the white/multi level witch works ok

    Please login or register to see this attachment.

    and I can also click on the little lamp to switch on/off.

    Link to comment
    Share on other sites

    1 minute ago, jgab said:

    For me the white/multi level witch works ok

    Please login or register to see this attachment.

    and I can also click on the little lamp to switch on/off.

    Weird

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    I'm not going to disturb you anymore with my problems. Thanks for all the help I get to use fibarose's built-in for so long until I find something that works

    Link to comment
    Share on other sites

  • Topic Author
  • 5 minutes ago, Freddan67 said:

    Weird

    Please login or register to see this attachment.

    Please login or register to see this attachment.

     

    Ah, if you turn brightness down max it becomes 0 and that is interpreted as off. I will change that so the brightness is at least 1, then the lamp icon will continue to be lit.

    1 minute ago, jgab said:

     

    Ah, if you turn brightness down max it becomes 0 and that is interpreted as off. I will change that so the brightness is at least 1, then the lamp icon will be lit.

     

    I don't have a lightstrip but they should behave like a "color light" according to the manual. 

    Edited by jgab
    Link to comment
    Share on other sites

    1 minute ago, jgab said:

     

    Ah, if you turn brightness down max it becomes 0 and that is interpreted as off. I will change that so the brightness is at least 1, then the lamp icon will be lit.

     

    I don't have a lightstrip but they should behave like a "color light" according to the manual. 

    Lightstrip retrieves correct brightness but still appears as off

    Link to comment
    Share on other sites

  • Topic Author
  • 52 minutes ago, Freddan67 said:

    Lightstrip retrieves correct brightness but still appears as off

    You could try this version

    Please login or register to see this attachment.

    - maybe it works better (at least it doesn't turn off the light icon when brightness is turned down to 0) - made some other small adjustments to 'Color light' too.

    I noticed that if I make a change in the Hue app it can take ~4s before the QA's state updates.

     

    No need to reinstall the lights - just copy paste code into the existing Hue QA.

    You are running the latest fw version for HC3 I assume?

     

    Link to comment
    Share on other sites

    2 hours ago, jgab said:

    You could try this version

    Please login or register to see this attachment.

    - maybe it works better (at least it doesn't turn off the light icon when brightness is turned down to 0) - made some other small adjustments to 'Color light' too.

    I noticed that if I make a change in the Hue app it can take ~4s before the QA's state updates.

     

    No need to reinstall the lights - just copy paste code into the existing Hue QA.

    You are running the latest fw version for HC3 I assume?

     

    Thanks. I'll try as soon as I get home again. Yes I use the latest version

    Link to comment
    Share on other sites

    2 hours ago, jgab said:

    You could try this version

    Please login or register to see this attachment.

    - maybe it works better (at least it doesn't turn off the light icon when brightness is turned down to 0) - made some other small adjustments to 'Color light' too.

    I noticed that if I make a change in the Hue app it can take ~4s before the QA's state updates.

     

    No need to reinstall the lights - just copy paste code into the existing Hue QA.

    You are running the latest fw version for HC3 I assume?

     

    Same issues

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • Tip.

    We can set an UI element with self:updateView(<element>,<type>,<value>)

    but there is no ready made function to get the value. We do get the values in the button/slider callbacks, but sometimes it would be nice to get the value directly.

    To get the value or text from an UI element 

    Please login or register to see this code.

    It take the deviceId as the first argument.

    Ex.

    print(getView(39,"myLabel","text"))

     

    There is an issue with slider element. They seem to have troubles updating their values when activated (moved)

    I have noticed that explicitly updating the view when a slider is activated helps to set the 'value' field of a slider.

    Ex.

    Please login or register to see this code.

     

    • Like 4
    Link to comment
    Share on other sites

    W dniu 17.03.2020 o 00:24, jgab napisał:

    In would be useful if conditions in scenes allowed for specifying a condition that would be true if the condition had been true for a specific time.

    In addition to "any" and "all" there could be a "trueFor", with a property "time" set to a time ex."00:05"...

    Ex. if a motion sensor has been safe for 5min, or if a set of motion sensors have been safe for 5min etc.

     

    Anyway, this is a thread about QAs, so let's do the second best thing...

     

    We compile expressions of type #<eventName>/<time to be true>/<interval for checks>/<expression>

    Please login or register to see this code.

    We actually put the rule in the QA'a quickappVariables

    name:#test

    value:00:05/2/100:safe & 101:safe & sunset..sunrise

     

    Anyway, we compile the expression into a Lua function that looks like

    Please login or register to see this code.

    numToBool converts a number to true or false if its >0, sunset and sunrise are variables bound to resp. time. (we have 'midnight' and 'now' also)

    We run it at every interval (2s in this case) and when it has been true for 5min we emit a CustomEvent with name 'test'

    We choose the interval depending on how quickly we need to be notified that an expression has been true.

     

    This allows us to use most of the power of Lua to craft our rules, we can do

    Please login or register to see this code.

    etc.

    The total code when we don't have to write a parser from scratch and interpret the result becomes quite compact (that's why load/loadstring would be appreciated)

    This code works as is but would probably need some more error checks etc before being "production ready"

    (Sorry for the long listing, but there are some techniques in the code that code be worth stealing...). QA attached at the end.

     

    Updated with same fixes and 'repeat' options.

    value=R00:05/2/88:on

    The starting 'R' indicates that the rule should continue to fire events every 5min the expression is true.

    Good to have if you want to have notification and reminders if a door/window is left open.

     

    New statewatcher compatible with 5.03.45

    Please login or register to see this attachment.

    Is it possible to add a date range to the conditions? so that, for example, the heating does not turn on from May to October despite the lower temperature? Or is it necessary to use the built-in date range block as the second condition for running the scene?

    Link to comment
    Share on other sites

    I wanna dancing change icon for my generic QA:

     

    1) find any multilevel sensor.

    2) found MS6 - humidity

    3) add icon

    4) added

    5) no. i do no want change. just close

    6) /api/icons find last User*

    7) PUSH number to brain :

    ? goto own QA. 

    Please login or register to see this code.

    where 1040 is POP from brain number :) 

    9) ctrl+S

    10) 

    image.png.a2ec1d73a75a1f6d5126c382ab281de4.png

     

    Edited by 10der
    Link to comment
    Share on other sites

  • Topic Author
  • 7 hours ago, michal85pl said:

    Is it possible to add a date range to the conditions? so that, for example, the heating does not turn on from May to October despite the lower temperature? Or is it necessary to use the built-in date range block as the second condition for running the scene?

    Lua has a date function. os.date("*t").month is the number of the month so the below could work.

    Please login or register to see this code.

    Next version I will add a 'month' variable that can be used directly.

    Link to comment
    Share on other sites

  • Topic Author
  • On 5/1/2020 at 10:28 AM, Freddan67 said:

    Same issues

    Please login or register to see this attachment.


    I loaned a hue white bulb from a friend and it  works flawless in my system. Really strange. Can you give me links to the exact product that misbehaves for you? Can’t sleep ?

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