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

1 hour ago, Krikroff said:

Hum... Strange.

i will try to reproduce when sonos are not available on network.

have you any problems with wifi ?

 

 

I solved a similar problem with my QA for iEast player.

Please login or register to see this link.

My conclusion is that workload problems are caused
1) communication failures on w-fi between devices (HC3 - audio)
2) HC3 - LAN communication outages
3) occasional mental problems HC3 own when you can not even save any parameter and the end of a 500/501 Internal Server Error

Link to comment
Share on other sites

2 hours ago, Krikroff said:

Hum... Strange.

i will try to reproduce when sonos are not available on network.

have you any problems with wifi ?

 

No I have no problems with wifi. At this moment only 5 Sonos players (not playing now), 2 camera's and an iPhone are using wifi (without problems). I deleted one of the two Sonos ZC QA's.

I rebooted the Orbi RBR50 router and the CPU load of the HC3 at the time of this reboot is:

Please login or register to see this spoiler.

I see from time to time a very short time error message at the bottom site, I saw the word "Error" and also "EOF" if I am not mistaken, all in red color.

Could it help to activate a sort of debug mode?

Edited by Rover
Link to comment
Share on other sites

There is clearly a communication fault between the HC3 and the network...
Is it possible that the Orbi RBR50 is blocking requests for some reason (ex: excessive polling) ? You also had a network access problem with the QA offered by @10der, didn't you?

Workaround in the next version, I can consider the possibility of completely interrupting the polling for a given time in the event of faulty communication between the HC3 and SONOS devices

  • Thanks 1
Link to comment
Share on other sites

8 hours ago, Krikroff said:

There is clearly a communication fault between the HC3 and the network...
Is it possible that the Orbi RBR50 is blocking requests for some reason (ex: excessive polling) ? You also had a network access problem with the QA offered by @10der, didn't you?

Workaround in the next version, I can consider the possibility of completely interrupting the polling for a given time in the event of faulty communication between the HC3 and SONOS devices

I do not think it is a network problem of the HC3. I checked in the log and rebooted the router: no difference.

Why is this excessive CPU load only present when Sonos ZC is active?

There was no network problem using @10der's Sonos_Hub, only a problem with the json encoding of the call parameters, what has been solved with help of @cag014.

I have set the Sonos ZC debug mode on:

Please login or register to see this spoiler.

 

Edited by Rover
Link to comment
Share on other sites

Hi All,

 

A quick question please:  I have a weather station data imported via MQTT to a QA with child devices, one child for each sensor.  In the labels of the QA the temperature shows correctly with the - sign.

Please login or register to see this image.

/monthly_2020_11/image.png.ff231357e1d14cdba3924cca4033c2ad.png" />

 

However, in the corresponding child the - sign does not show.

image.png.7ccf1df975de156c152f74a83afcf59e.png

 

I am updating the data to the child device with :

self:updateProperty("value",(data.temperature))

 

The debug shows it  being a negative number.

image.png.5f4ef70978493c239e17edb52c491be8.png

 

Any idea please ?

 

Thank you

 

 

Link to comment
Share on other sites

9 hours ago, Momos said:

Any idea please ?

search post on the forum by @afendikovwith subj "fibaro be carriful with rounding float values" :) 

Fibaro... it's fibaro.

Link to comment
Share on other sites

  • Topic Author
  • Someone asked for a simple example for a write/read to a socket. Som devices has simple text based protocols over sockets to control them.

    This example is similar to the Fibaro TCPSocket example but maybe a bit simpler. This also creates new sockets for each requests (sockets can't be reused after closed, so it requires some extra code to keep a socket alive as long as possible and still cater for errors)

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    1 hour ago, 10der said:

    search post on the forum by @afendikovwith subj "fibaro be carriful with rounding float values" :) 

    Fibaro... it's fibaro.

    Gaahh ... i have nothing more to say 

    • Thanks 1
    Link to comment
    Share on other sites

    ahaha ??  My response was targeted at Fibaro ?  I can not belive such a thing can actually exist in a device nowadays.  Especially in one with a high price tag.

    Edited by Momos
    Link to comment
    Share on other sites

    How to change size and color of text in self:updateView?

    How to change background color of QA buttons?

    Link to comment
    Share on other sites

  • Topic Author
  • 9 minutes ago, Rover said:

    How to change size and color of text in self:updateView?

    How to change background color of QA buttons?

    People have managed to put HTML tags in the label text. It may not work in all browsers/apps.

    Link to comment
    Share on other sites

    47 minutes ago, jgab said:

    People have managed to put HTML tags in the label text. It may not work in all browsers/apps.

    In Edge as well as Firefox self:updateView("btn_SPH", "text", "<font color=#fd7e14>Setpoint Hoog) shows in the button: font color=#fd7e14>Setpoint Hoog

    Link to comment
    Share on other sites

  • Topic Author
  • 12 minutes ago, Rover said:

    In Edge as well as Firefox self:updateView("btn_SPH", "text", "<font color=#fd7e14>Setpoint Hoog) shows in the button: font color=#fd7e14>Setpoint Hoog

    Labels it works for, buttons no.

    Link to comment
    Share on other sites

    1 minute ago, jgab said:

    Labels it works for, buttons no.

    So string formatting or color change of buttons is always a nogo?

    Link to comment
    Share on other sites

  • Topic Author
  • Well, it's possible if you hack the viewLayout property yourself. 

    The problem is that the UI can't be edited in the HC3 Web editor anymore. In fact, if you just re-save the QA the viewLayout is "reset". So I would say that's it not really that useful until Fibaro starts to support better layouts.

     

    I do all my coding offline in ZBS and the UI spec allows me to add funky UI layouts if I need (but I usually don't)

    Please login or register to see this image.

    /monthly_2020_12/labels.png.33ceb04c7f804388f89e962da68e5e85.png" />

    using the code

    Please login or register to see this code.

     

    Here is a even more interesting QA with pop-ups etc.

    <

    Please login or register to see this link.

    >

    • Like 2
    Link to comment
    Share on other sites

    • 3 weeks later...
    On 4/19/2020 at 6:28 PM, jgab said:

    There have been posts about getting triggers/events in QAs using the /refresStates API.

    This post is nothing new but wraps the logic in a 'SourceTrigger' class

    Please login or register to see this code.

     

    If we have this class we can use it like this

    Please login or register to see this code.

    The functions we define on SourceTrigger has the name <type>_<property>

    Please login or register to see this code.

    will be called with 'source triggers' of type {type='device', property='value' ...}

    If we define

    Please login or register to see this code.

    we will get all triggers of type {type='device', ...}

    For triggers without a 'property' field we only have the type.

    The intention is that the triggers should look like the sourceTriggers available for Scenes.

     

    If we need different trigger loops we can subclass 'SourceTrigger'

     

    Dear all,

     

    first of all, thanks for this excellent post. I migrated all of my HC2 stuff to HC3 with basically just this thread as a reference. Kudos to @jgab@petergebruers and all the other folks.

     

    I have some QAs working as MQTT subscribers, 528 and 542. The publisher sends a single update, so two QAs get updated at the same time. The update of 528 triggers the update of another QA (535). These QAs are updated correctly. But the SourceTrigger QA from the post on page 17 gives:

     

    Please login or register to see this code.

     

    I don't understand why 542 or 528 are missed most of the time. Two events that happen at the same time should be caught by

     

    Please login or register to see this code.

     

    Is this some crazy race condition? Maybe not, because setTimeout on self:updateProperty in 528 does not really help missed triggers. And it is not a nice solution.

     

    Do you have any futher suggestions how to tackle this problem?

     

    Cheers, jayrock

     

    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, jayrock said:

     

    Dear all,

     

    first of all, thanks for this excellent post. I migrated all of my HC2 stuff to HC3 with basically just this thread as a reference. Kudos to @jgab@petergebruers and all the other folks.

     

    I have some QAs working as MQTT subscribers, 528 and 542. The publisher sends a single update, so two QAs get updated at the same time. The update of 528 triggers the update of another QA (535). These QAs are updated correctly. But the SourceTrigger QA from the post on page 17 gives:

     

    Please login or register to see this code.

     

    I don't understand why 542 or 528 are missed most of the time. Two events that happen at the same time should be caught by

     

    Please login or register to see this code.

     

    Is this some crazy race condition? Maybe not, because setTimeout on self:updateProperty in 528 does not really help missed triggers. And it is not a nice solution.

     

    Do you have any futher suggestions how to tackle this problem?

     

    Cheers, jayrock

     

     

    If you update the property of a QA (ex. the value property) it will only generate an internal trigger (event) if the value differs from the current value.

    Ex. self:updateProperty("value",fibaro.getValue(self.id,"value")) will not generate a trigger.

    Also, do your MQTT send events if the value changes or with regular intervals?

    • Like 1
    Link to comment
    Share on other sites

    59 minutes ago, jgab said:

     

    If you update the property of a QA (ex. the value property) it will only generate an internal trigger (event) if the value differs from the current value.

     

    Thanks, that makes a lot of sense. Indeed the value does't change that often. It also explains why some sensors seemed to work "better".

     

    59 minutes ago, jgab said:

    Also, do your MQTT send events if the value changes or with regular intervals?

     

    Yes, the devices do send on regular intervals, that means they send an update (which can be observed via MQTT) even if the value hasn't changed.

     

    Let me do some more monitoring and see if this is the explanation.

     

    Cheers,

    jayrock

    Edited by jayrock
    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...