Automation won't respond to Input Boolean trigger

I’m trying to achieve the following:

Apple HomeKit switch
switches an
Input Boolean
the state change of which triggers an
Automation
the action of which runs a
Script

So far:

  • HomeKit successfully switches the Input Boolean
  • The Input Boolean state change fails to trigger the automation
  • The automation (when triggered manually) successfully runs the script
  • The script does what it’s supposed to

All elements appear in the browser front-end and there are no syntax errors that I can see.

I’m defining my Input Boolean in configuration.yaml like this:

# Input Booleans
input_boolean:
  tv_switch_bool:
    name: TV on
    initial: off

and my automation like this

# Automations
automation:
# Turn on TV and Virgin Media box
  - alias: 'TV On'
    trigger:
      - platform: state
        entity_id: input_boolean.tv_switch_bool
        to: 'on'
    action:
      - service: script.turn_on
        entity_id: script.tv_activity_on

I’ve been fiddling with this for hours, and I got it working briefly by deleting my automation and rewriting it by editing a pasted in example, so I figured I must have had a YAML formatting problem. But then I added in the next bit - automating a script from the input boolean state change from ‘off’ to ‘on’ - and it broke again. So I’ve gone back to just the one automation and it won’t work again!

Like I say: the script works fine, the automation works fine when triggered manually, and the input boolean responds to HomeKit, so its the Input Boolean to Automation bit that needs fixing.

Thanks for you help!

EDIT:

I manually installed Home Assistant (without hass.io) on Raspbian on a Raspberry Pi 2 B Rev 1.1.

Is the automation switched on?

Try adding initial_state: on to ensure it’s running.

Also, unless you have something switching the boolean back off, this is only going to work once per restart of homeassistant.

Thank you! I misunderstood what the ‘state’ of an automation meant. I should have posted on here hours ago!

1 Like

I have the opposite problem. HomeKit automations won’t switch input_booleans on/off. configuration.yaml::

#HomeKit home switches
input_boolean:
  gak_present:
    name: homekit_trigger_1
    icon: mdi:skull
    initial: on
  ssk_present:
    name: homekit_trigger_2
    icon: mdi:alien
    initial: on
# Hassio -> HomeKit configuration
homekit:
  filter:
    include_domains:
      - alarm_control_panel
      - input_boolean
  entity_config:
    alarm_control_panel.alarm:
      code: !secret alarm_code
    input_boolean.gak_present:
      name: gary
    input_boolean.ssk_present:
      name: shannon

Manual switching in HK works and reflects back to HA. Works the other way also.

These are the HK automations for switching presence booleans when device_tracker.<iPhone> is detected at Home. One for when the phone nears home; one for when phone leaves.

The HK room displaying the switches (gary/shannon):

These are the device tracking entities of which gary/gryphon are the two iPhones, and homekit_trigger1 and 2 are the booleans on the HA side. The Presence binary sensors are bayesian based on the other three inputs.

I’m new to HA and have been scratching my head for a couple of days. I realize device tracking is the tough part, but it’s essential for an automated home. Any ideas?