MQTT subscribes on UiFlow



  • Did anyone try to had more than 1 subscribe by MQTT protocol ant how it made?



  • Hi there.
    I have exactly the same problem.
    I can subscribe to one topic and show the value on the screen.
    But when i do it with the second topic then it doesn't work anymore.
    Has anyone a solution for this?
    I want to show different states from the homeassistant mqtt statestream.



  • @maltim I use adafruit.io via mqtt and subscribe and display two feeds values. I use uiflow 1.4.2 firmware in my StickC. Se on my code mqtt_example



  • @robalstona Thank you. I already learned alot out of your code. I will try that out.
    I'm looking forward for my mqtt value screen ;-)



  • @robalstona
    I tried again with your code but nothing happens to the screen. Not even one value apears.
    I see them in MQTT Lens. 0_1579035595487_Capture.PNG
    Anyone a Hint? I have 1.4.3 on the m5 core and on the ui flow.



  • Has this something to do that i receive the value solar without float and zaehler with float?



  • @buhi It is possible that the problem is how the data is sent to the mqtt server and how often they are sent. In my case, the sensor data is sent every 25 seconds. And if I run this program it will only show me --- until the server receives new data. and then the channel is subscribed, the data are saved to the variable and displayed on the lcd display. So if you have data updated, for example, every hour, nothing may be displayed for an hour. You can combine something with the "retain" flag when sending data to the server, then you will be able to receive the last data received from the feed. But this already needs to be changed on the device / software side that this data sends.

    https://mntolia.com/mqtt-retained-messages-explained-example



  • @robalstona Ok i understand enough from MQTT how it works. They are published to my Broker every second.
    But strange is that this code below with one subscribe topic works.
    First both variables get "0" after the 3500ms wait solar gets update with 0.0 (now its night here so no solar power)
    0_1579123155832_m5_stack_mqtt.PNG
    Because i have two solaredge inverters i have two different values in the same format.
    So if i try to get the second one also with mqtt subscribe to a different topic (2nd inverter) the hole screen is black. Any hints?



  • @robalstona said in MQTT subscribes on UiFlow:

    @buhi It is possible that the problem is how the data is sent to the mqtt server and how often they are sent. In my case, the sensor data is sent every 25 seconds. And if I run this program it will only show me --- until the server receives new data. and then the channel is subscribed, the data are saved to the variable and displayed on the lcd display. So if you have data updated, for example, every hour, nothing may be displayed for an hour. You can combine something with the "retain" flag when sending data to the server, then you will be able to receive the last data received from the feed. But this already needs to be changed on the device / software side that this data sends.

    https://mntolia.com/mqtt-retained-messages-explained-example

    I opened a request for UIFlow to add support for the retain flag. You can track it here.

    https://github.com/m5stack/UIFlow-Code/issues/1



  • @buhi said in MQTT subscribes on UiFlow:

    @robalstona
    So if i try to get the second one also with mqtt subscribe to a different topic (2nd inverter) the hole screen is black. Any hints?

    Are there any errors on HomeAssistant? I use Adafruit IO and when I get a black screen due to an issue configuring something in UIFlow , typically I can see some errors on the broker’s web console.

    It could be your feed configuration or the sensor data (stored as float or int instead of strings) or something like that.



  • I have the exact same problem. 1 topic works fine, but more does not work.



  • Two topics is working for me with Adafruit IO and this example flow. I'm using uiFlow V1.4.4 and firmware V1.4.3 on the grey M5Stack core (since firmware V1.4.4 currently has some issues).

    0_1579271908570_Screen Shot 2020-01-17 at 9.36.39 AM.png

    I'm not using HomeAssistant and do not have any real sensors that I'm pulling data from. However, the two topics is working for me when I simulate sensor data with button A and B presses, or when I add the data manually via the AIO feed console.

    I'll try to set up HomeAssistant on a RPi and see if anything changes.



  • @world101 Your example does not read the topics, it's being set when you push the buttons....



  • @skysurfer said in MQTT subscribes on UiFlow:

    @world101 Your example does not read the topics, it's being set when you push the buttons....

    You are correct. I'm having the same issues as you.