Input Boolean appearing in HA but not working. Please help?

Hi Everyone,

I’m having an issue with an Input Boolean not working, despite being pretty sure that I had it working in the past with some advice from @Vasiley

I have my Xiaomi Vacuum working with HA, and have it appearing twice in HomeKit, once for the switch (which successfully turns the vacuum on and off but does not report back to homekit when it is done) and one for the Input Boolean, which just does not control the Vacuum with either HA or Homekit.

I’d like to get the input boolean working, especially with HomeKit but at least in HA. I am assuming I have something set up incorrectly.

My knowledge level is medium, I don’t have a separate automations file or anything and would like to keep it all in configuration.yaml if possible :frowning:

Does anyone have any hot tips on making this input boolean work? Here’s my config.

Thank you all

vacuum:
  - platform: xiaomi_miio
    host: 192.168.0.118
    token: *PrettySureThisIsSecret*

xiaomi_aqara:
  discovery_retry: 5
  gateways:
    - key: **SECRET too?**

input_boolean:
   xiaomi_vacuum_cleaner:

switch:
- platform: template
  switches:
      xiaomi_vacuum_cleaner:
        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

I am guessing what you are trying to do here with the input_boolean, but if you want to use it as a dummy ‘indicator’ for on/off state the reason it is not working because you declare it, but you never change boolean state. You have to change it’s state so your template switch (value_template) gets a different state as well.

However in your case I think it’s totally unnecessary to use any input_boolean. You may delete the input_boolean entry and modify your template switch value_template entry as this:

value_template: '{{ not is_state("vacuum.xiaomi_vacuum_cleaner", "docked") }}'

Explanation:
your Xiaomi vacuum entity has docked state when it is sitting on the dock. All you need to do is to monitor this condition. Whenever it leaves the dock (for cleaning), the state will change and the value_template expression becomes True indicating that the vacuum is working. I used 'not' in the expression as you want to see OFF when it’s docked.

1 Like

The below seems to have the correct spacing… it’s probably your problem. (your spacing is incorrect, the below is correct I think) YAML is picky.

input_boolean:
  xiaomi_vacuum_cleaner:

switch:
  - platform: template
    switches: