Input Boolean switch set-up question (trying to trigger Xiaomi Vacuum start service)

Hi Everyone,

I’ve had some great advice that the way to get a start button for the xiaomi vacuum in Homekit was to create an ‘input boolean’ (queue googling what that means whilst at work). I was able to stitch this together from an example posted and paste it into my configuration.yaml, but it is not working.

Could anyone that knows more than me please show me (in terms that an idiot might understand) how to edit this and make it work. The dream is to have a switch that shows up in Homekit that when switched ‘on’ triggers the vacuum.start service and when switched ‘off’ triggers the vacuum.return_to_base service.

just can’t see how to rewrite this in a way that will work!

Thank you all.

From my configuration.yaml

input_boolean:
  heatpump_upstairs_power:
  vacuum.xiaomi_vacuum_cleaner:
    name: XiaomiVac

switch:
    heatpump_upstairs_power:
    vacuum.xiaomi_vacuum_cleaner:
      value_template: '{{ states("input_vacuum.xiaomi_vacuum_cleanerr") }}'
      friendly_name: 'XiaomiVac'
      turn_on:
        - service: vacuum.start
          entity_id: vacuum.xiaomi_vacuum_cleaner
        - service: vacuum.start
      turn_off:
        - service: vacuum.return_to_base
          entity_id: vacuum.xiaomi_vacuum_cleaner
        - service: vacuum.return_to_base
input_boolean:
  xiaomi_vacuum_cleaner:
  name: XiaomiVac

switch:
  - platform: template
    switches:
      heatpump_upstairs_power:
        value_template: '{{ states("input_boolean.xiaomi_vacuum_cleaner") }}'
        turn_on:
          service: vacuum.start
          data:
            entity_id: vacuum.xiaomi_vacuum_cleaner
        turn_off:
          service: vacuum.return_to_base
          data:
            entity_id: vacuum.xiaomi_vacuum_cleaner

would be correct syntax if thats the way you are wanting to do it …but there are a thousand ways to do it. Not the way i would but? Here is how i did it
Home-Assistant-Main/packages/xiaomi_vacuum_automations.yaml at 4c7a5c6f674f64695f04e57b7a2fddab953a9f78 · Vasiley/Home-Assistant-Main · GitHub and seperate packages for rooms

Wow. You are a legend @Vasiley thank you.

The switch shows up in HomeKit now, but it doesn’t appear to trigger the Vac when it’s turned on/off. I get an error when I log into HA saying that “the following platforms and components could not be set up: input-boolean”.

If I’m honest, I’m still not totally sure how to get the logs out of HA. I put “logger:” in my configuration.yaml so I will take a look. My understanding is that the logs will show me specifically what is wrong.

One more question… there’s an artifact of the ol can-n-paste job that I did, you can see the “heatpump_upstairs_power” name under “switches:” should I be changing that to acuum.xiaomi_vacuum_cleaner or XiaomiVac?

Thanks mate!

I have the same use case, a simple switch to use in HomeKit. There’s actually no reason to use an input_boolean for that, you can get away with a templated switch. Here’s the single switch that works for me:

switch:
  - platform: template
    switches:
      homekit_vacuum_main:
        friendly_name: "Main Vacuum"
        value_template: '{{ is_state("vacuum.xiaomi_vacuum_cleaner", "Running") }}'
        turn_on:
          service: vacuum.start
          data:
            entity_id: vacuum.xiaomi_vacuum_cleaner
        turn_off:
          service: vacuum.return_to_base
          data:
            entity_id: vacuum.xiaomi_vacuum_cleaner

Hope that helps, even a few months later.

1 Like