Announcement

Collapse
No announcement yet.

Controlling Xiaomi vacuum in Home Assistant from HS3 via MQTT

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Controlling Xiaomi vacuum in Home Assistant from HS3 via MQTT

    Anyone done this? I'm using this component in Home Assistant (hassio): https://www.home-assistant.io/compon...m.xiaomi_miio/

    Mosquitto MQTT-broker is running on the hassio RPI, MQTT configured in hassio. mcsMQTT running on HS3, getting input from hassio (see picture).

    Being rather new to both Home Assistant I'd really like a step by step howto starting, stopping, docking the Xiaomi from HS3...

  • #2
    I have Xiaomi vacuum at another location that I will not be able to get to until April.

    Looking at your links it appears that the MQTT message that you need to send to start a cleaning cycle is "homeassistant/vacuum/command" with a payload of "start". Change payload to "stop" or "pause" for other controls.

    In most setups there is one status topic with a payload to indicate the current status. In this miio implementation they have elected to publish each status is a separate topic and the payload being the time when the status changed. This implementation makes is a little more awkward to setup a normal interface.

    What I would like to setup is a single HS device that controls the state and this device would be the parent of the .../clean_start, clean_stop, and clean_pause subscribed topics devices. Three buttons would be presented in HS UI for stop, start, pause. Receipt of of .../clean_stop, for example, would update the status of the parent device. For something like this the use of events or script would be needed today. I would need to play a little to set it up or possibly generalize an implementation that would be build into the plugin. Give me some time to work with it.

    In a very basic implementation one would take your device 2971 and give it a Pub: text box entry of "homeassistant/vacuum/command" and onl the Edit tab use "start" for the payload template and Text radio for the control UI. This should present a text box in HS Device Management and entry of any text in that text box would result in publishing "homeassistant/vacuum/command/start" to control the vacuum. Rather than selecting "Text" one could select "Button" for the radio. The issue is that HS expects discrete payload values for this type of UI and it will be getting date-formatted text. I need to play to see if there is a work-around in the setup to give you a single "Start" button that would accomplish the same thing as the text box UI for the Text UI type.

    Comment


    • #3
      I did confirm that the straightforward approach of using Text as the Control UI does work as expected. I will look into the others a little later. Type anything into the text box to overwrite the date and in this example the message vacuum/command with payload of start is delivered. When the vacuum delivers the time update for starting it will update the subscribed device.

      In this example the grouping parent ref is no significant. What is needed is the Pub Topic, Control/Status UI, and Payload template are the operative entries. The topics that I used are just something that was on my test machine and have nothing to do with your specific topics needed for vacuum control.

      Click image for larger version  Name:	Capture.PNG Views:	1 Size:	20.6 KB ID:	1293643Click image for larger version  Name:	Capture1.PNG Views:	1 Size:	89.6 KB ID:	1293644

      Comment


      • #4
        Great, I'll give it a try

        Comment


        • #5
          I have made an update that is described at https://forums.homeseer.com/forum/li...tt-version-3-6

          In the manual (http://mcsSprinklers.com/mcsMQTT.pdf Section 4.1.27 I provide instructions on how to setup your scenario with one HS device to control start/stop/pause.

          Comment


          • #6
            That's very nice of you - now if I just could get some time to implement this in my installation...

            Comment


            • #7
              Any updates on this? Mike, did you get to your remote vacuum?

              Comment


              • #8
                Yes I obtained the vacuum but totally forgot about trying this with it. I believe what I provided will work to give the desired behaviors. Next time with my vacuum will be early July.

                Comment


                • #9
                  Finally had time to look more into this. As it happens, Home Assistant doesn't actually listen to MQTT, so the command will never be executed or sent to the vacuum-component in Home Assistant. There has to be some work done within Home Assistant to make this work, but I haven't gotten that far yet as I'm a total newb at HA. However, this link probably points in the right direction: https://community.home-assistant.io/...-devices/77787

                  Comment


                  • #10
                    The info you posted at the start of the thread shows the MQTT interface does exist and the changes I made to mcsMQTT should make it easy to use that interface. The latest link you posted does not appear to have anything to do with the vacuum, but was a more general question about MQTT use. In post #3 I showed how mcsMQTT would be setup to be able to send a start command to vacuum using HS controls.

                    Comment


                    • #11
                      I'm no expert at neither MQTT nor Home Assistant, but as I understand it, Home Asisstant does nothing with commands published to it through MQTT unless you add some logic to Home Assistant to handle the commands. I might be mistaken, someone with more experience with Home Assistant please correct me if I'm wrong

                      Comment


                      • #12
                        Take a look at iobroker. it is by far, easier to send values etc via mqtt (with the nodered service of Iobroker). And if you happen to have to use the iobroker api, it is as simple as the json hs3 one!


                        I dropped openhab and home assistant, and i just run iobroker now. Really happy with the move.

                        here is the iobroker Xiaomi vacuum cleaner adapter https://www.npmjs.com/package/iobroker.mihome-vacuum

                        Comment


                        • #13
                          Originally posted by mk1 black limited View Post
                          I'm no expert at neither MQTT nor Home Assistant, but as I understand it, Home Asisstant does nothing with commands published to it through MQTT unless you add some logic to Home Assistant to handle the commands. I might be mistaken, someone with more experience with Home Assistant please correct me if I'm wrong
                          That’s a way to do it. Or simpler, add the home assistant websocket node red package to nodered.
                          Create an secret key from home assistant...and write it in the home assistant ws nodered package in nodered.
                          Then send the payload to and output mqtt node. From there you will be able to grab the topic in the mcsmqtt plugin.

                          Comment


                          • #14
                            Here( 1s picture) is how i do my alexa '' room awareness '' from iobroker to hs3 . Nodered and mcsmqtt make it really easy.


                            It's the same principle with whatever you want from home assistant. you'll want to add some node in between like i did here ( 1st picture)... but sometime it is not necessary like in my second picture ( here, I get the status of my 3 emby clients to hs3 without any node in between).







                            Attached Files

                            Comment

                            Working...
                            X