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


  • 2

HC3 and MQTT in QA


Guest kallecux

Question

Guest kallecux

Hello! - Happy Easter!

 

I try to play with the new MQTT-functionality in QA's, but im am not successful.

There i have a MQTT broker on Hassio and this code on HC3:

 

Please login or register to see this code.

When i save the QA i get this message on HC3:

[13.04.2020] [13:33:33] [DEBUG] [QUICKAPP353]: onConnected: {"sessionPresent":false,"returnCode":0}

 

The Broker says this:

1586777612: New connection from 192.168.3.116 on port 1883.
[INFO] found hc3 on Home Assistant
1586777613: New client connected from 192.168.3.116 as randomjdtfpexjvy (p2, c0, k0, u'hc3')

 

So i think everything is OK, but i get no:

- onSubscribeMessage when the QA started

- onPublished Message when i toggle the switch 

 

Is there anybody who can give me a hint?

Thanks in advance.

Karl Heinz 

 

Edited:

When i toggle the QA Switch, the message is transferred to the broker and the other clients (NodeRed-Cient), but the function onPublished is NOT called! 

I think the callback / envent is not executed, so i can not get the subscribed data. :-(

 

Edited by kallecux
Link to comment
Share on other sites

Recommended Posts

  • 1

Your call

   self.client:subscribe("#")

Appears last in the "init" function but... It executes before the client actually connects, so it does not actually subscribe to anything. Wireshark is your friend :DMove the "subscribe" and anything you want to do to the onConnected handler, which, as the name implies, runs exactly after the MQTT client got connected.

 

Like this:

 

Please login or register to see this code.

 

Edited by petergebruers
  • Like 1
Link to comment
Share on other sites

  • 1
2 hours ago, jgab said:

 

What value range is payload.hue ?

Sliders usually takes 0-99

Value range of hue is 0 - 359. I know that i have to devide the value with 3.59. 
 

 

Link to comment
Share on other sites

  • 0
Guest kallecux
  • Inquirer

  • Isn't there anyone around playing with MQTT and HC3?

     

    Link to comment
    Share on other sites

    • 0

    How is MQTT behaving for everyone here? Is anyone using it for more than just testing? 

    I'm having an issue where everything works perfectly after I set it up. But stops working few hours later. It looks like the MQTT client gets disconnected for whatever reason and does not reconnect.

     

    I was wondering if I need to create a loop in my QA's init function to reconnect periodically?

     

     

    Link to comment
    Share on other sites

    • 0
    Guest kallecux
  • Inquirer
  • It works without problems for me, i receive every minute temperature and humidity from an MQTT Server into my QA.

    Greetings

    Link to comment
    Share on other sites

    • 0
    Guest kallecux
  • Inquirer
  • Hi @gooba this is my code:

    Please login or register to see this code.

    Greetings

    Karl Heinz

    Link to comment
    Share on other sites

    • 0

    I've been testing MQTT with different codes and approaches now - including your code above, @kallecux. Using different MQTT brokers (local, remote and cloudMQTT) They all seem to behave the same way. They would work for a few hours and then stop. Also, when they stop working, I see no error message in the debug:

     

    Please login or register to see this code.

    I have descriptive debug messages included into the code to see at which point the QA fails, but none of them show up, not even the very first debug message of onInit function.

    Link to comment
    Share on other sites

    • 0
    Guest kallecux
  • Inquirer
  • Hello @Rait i have no problems - write a ticket to the fibaro support team.

     

    Greetings!

    Link to comment
    Share on other sites

    • 0
    Guest kallecux
  • Inquirer
  • I can try to take a look at your code.....

    Link to comment
    Share on other sites

    • 0

    @kallecux my code is literally identical to yours.

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    • 0

    I added keepalive and cleanSession options to my QA's now. Let's see if it makes a difference

    Link to comment
    Share on other sites

    • 0

    Also, another thing I noticed. I need to keep my message event listener quite short, or else it will not run all the way to the end.

    For instance, I get temperature, humidity, relay and some variable data from different topics. I can only check for 3 different things. The rest does not get triggered. I can verify that the checks work individually because If I move the checks around then it's always the three first things that get checked.

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    • 0

    Can you register different callbacks for each topic (humid, temp etc). Now you seem to have one big callback?

    Alternatively, what happens if you do

    Please login or register to see this code.

    or, even more chopped up

    Please login or register to see this code.

    The idea is to give time for the MQTT client to process messages... if that is the problem. 

    Link to comment
    Share on other sites

    • 0

    My MQTT QuickApps have been running without interruptions for about 24 hours now. So seems like adding either keepalive or cleansession to my options fixed the disconnection issue. 

     

    Thanks @jgab I'll look into having separate callbacks for each data type. See if that solves my other issue.

    Link to comment
    Share on other sites

    • 0

    DELETED. wrong topic

    Edited by 10der
    Link to comment
    Share on other sites

    • 0

    DELETED. wrong topic

    Edited by 10der
    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...