Replies: 7 comments
-
Have this working in a GUI interface. Just not sure how to turn this to code: |
Beta Was this translation helpful? Give feedback.
-
I previously did some digging into this topic, and likewise was able to use a GUI tool (MQTT Explorer) to connect and subscribe to /events, /response, and /status to get nearly real-time updates regarding the player, and strongly feel it's the right approach to use from HA. On your questions, (2) I tried using the add-on mqtt mosquitto by creating a .conf file for bridging mosquitto but as you said, it's all manual config so not a realistic solution given the context, which leaves us with solution (1) using a mqtt broker for the HA integration. I did some extensive searching for existing integrations that mimic what we're trying to accomplish (a) authenticate via API then (b) switch to using mqtt over websockets for status updates from AWS. There are several python libraries that support mqtt over ws, including paho, websockets, and aiohttp (which is the one used by HA to expose HA data). The closest example I located is the sound machine / light appliance Rest. The integration authenticates to an API, then using the awsio library uses mqtt over ws for updates. Here is the HA Integration, and here is the API. Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Yes it helps for sure! I am very tempted to pull the mqtt up a level to the HA component but also was hoping to keep them split. By keeping them split others can consume this python API for other uses. With the APIs you provided I am going to spend some time focused on that before I loop back to fixing MQTT. Leaving anything that can be done on MQTT for that. APIs will be focused on items I don't think can be done elsewhere. |
Beta Was this translation helpful? Give feedback.
-
I thought I might chime in with another integration that works the same way (MQTT). It's called hassio-ecoflow-cloud and it appears to do the same authentication flow and then switching to MQTT for updates. The way many of these IoT apps are built today, is that the vendors run a large MQTT broker (e.g., on AWS), and then client applications connect to the broker to receive updates. It appears Yoto is doing this, so as you've seen connecting to the broker results in receiving near-realtime updates about the status of the players. This is much more efficient than polling some REST endpoint every few seconds or minutes. But I did want to clarify that you probably do not need to implement a broker. Yoto runs the broker, and the integration will be a client. It's just a matter of figuring out how to get an authentication token and then subscribe to the MQTT broker and listen for updates on the correct topics. You two have already done most of the legwork on this, so it looks like the last part is integrating with home assistant entities and such. Take a look at the ecoflow integration code to see if that clarifies things. And again thanks for the excellent work! |
Beta Was this translation helpful? Give feedback.
-
Thank you! I will take a look at that one as well. I am wondering if I can leave the MQTT within the API package I have built but can that client in the HA side. My goal is to have an API package that can be consumed on other platforms as well. I will need to do some testing to see if that works. This is a bit more advanced than my skills so learning as I go. |
Beta Was this translation helpful? Give feedback.
-
In preparation for using mqtt for updates, I've compared the keys in the status API vs the mqtt status topic. It seems appropriate to first populate the HA sensors with the API values when authenticating, then switch to the mqtt values.
|
Beta Was this translation helpful? Give feedback.
-
I am very much struggling with how the architecture should look to get MQTT going. Anyone with more mqtt, HA and async experience than I how could mock it up? Once the client is functional in HA I am sure I can keep expanding it. |
Beta Was this translation helpful? Give feedback.
-
Thought I would start a thread on where I am at. I have the data for cards and device IDs working. Authentication is also good.
Next up is device control / real status data. What I know so far:
We just need to pass the variables already available.
Now I don't know MQTT so what I am trying to figure out:
Beta Was this translation helpful? Give feedback.
All reactions