Help with Toggle as Trigger

I have an automation to turn on a group of radiator trv’s. I tested the automation initially with a time trigger and it worked as expected.

However, I then created an input boolean toggle in the UI and wanted to use that to trigger the automation instead. I amended only the trigger but it now won’t run.

The only entry in the log each time it fails is a Spook error which doesn’t specifically name either the automation or script but it appears each time I try to trigger the automation using the toggle.

Can anyone please help with what I’m not seeing.

Script:

home_heating_on:
  alias: Home Heating ON
  sequence:
  - service: climate.set_temperature
    data:
      entity_id: group.thermostats
      temperature: 19
  mode: single 

Automation:

- alias: Heating All Rooms ON
  id: heating_all_rooms_on
  mode: single
  trigger:
  - platform: state
    entity: input_boolean.home_heating
    to: 'on'
  condition:
  - condition: state
    entity_id: input_boolean.holiday_mode
    state: 'off'
  action:
  - service: script.turn_on
    entity_id: script.home_heating_on

Spook Error:

This error originated from a custom integration.

Logger: custom_components.spook
Source: helpers/debounce.py:114
Integration: Spook (documentation, issues)
First occurred: 8:38:42 AM (227 occurrences)
Last logged: 11:09:33 AM

Unexpected exception from <function AbstractSpookRepair.async_activate.<locals>._async_inspect at 0x7f59599e7a60>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 114, in _handle_timer_finish
    await task
  File "/config/custom_components/spook/repairs.py", line 130, in _async_inspect
    await self.async_inspect()
  File "/config/custom_components/spook/ectoplasms/script/repairs/unknown_entity_references.py", line 99, in async_inspect
    for entity_id in entity.script.referenced_entities
                     ^^^^^^^^^^^^^
AttributeError: 'UnavailableScriptEntity' object has no attribute 'script'

  action:
  - service: script.turn_on
    entity_id: script.home_heating_on

I would use


  action:
  - service: script.home_heating_on

or


  action:
  - service: script.turn_on
    target:
      entity_id: script.home_heating_on

1 Like

Thanks for you help. I’ve tidied up the action in the automation using your first example but it still didn’t work. Nothing appeared in the logs but I spotted my error in the original automation, I’d entered entity: instead of entity_id:.

Strange how this wasn’t picked up in the logs though.

All working fine now with the below:

- alias: Heating All Rooms ON
  id: heating_all_rooms_on
  mode: single
  trigger:
  - platform: state
    entity_id: input_boolean.home_heating
    from: 'off'
    to: 'on'
  condition:
  - condition: state
    entity_id: input_boolean.holiday_mode
    state: 'off'
  action:
  - service: script.home_heating_on

Slipped my attention, too. Well, the devil lies in the details.

1 Like