Hello.
I have an automation which turns off bathroom lights. I have no idea why, but it stopped working in some point. Can not found what I have messed up.
Here is my automation:
- id: '1538321511928'
alias: Bath off on door motion and light
initial_state: 'on'
trigger:
- entity_id: binary_sensor.door_window_sensor_158d0001e5d691
platform: state
to: 'on'
condition:
- condition: time
after: '4:30:00'
before: '21:00:00'
- condition: state
entity_id: binary_sensor.motion_sensor_158d000224aa83
state: 'on'
- condition: state
entity_id: switch.wall_switch_right_158d000245c5ca
state: 'on'
action:
- entity_id: script.1556739575120
service: script.turn_off
- service: script.1556739575120
And here is a script:
'1556739575120':
alias: Bath wait for humidity then off
sequence:
- delay: 0:0:1
- condition: state
entity_id: binary_sensor.door_window_sensor_158d0001e5d691
state: 'on'
- delay: 0:2:0
- condition: state
entity_id: binary_sensor.motion_sensor_158d000224aa83
state: 'off'
- wait_template: "{{ states('sensor.humidity_158d0002279c7d')|float < 65 }}"
timeout: '00:30:00'
- condition: state
entity_id: binary_sensor.motion_sensor_158d000224aa83
state: 'off'
- condition: state
entity_id: switch.wall_switch_right_158d000245c5ca
state: 'on'
- data:
entity_id: switch.wall_switch_right_158d000245c5ca
service: switch.turn_off
And here is the issue from logs.
Thu Oct 10 2019 09:09:24 GMT+0300 (Москва, стандартное время)
Error while executing automation automation.bath_off_on_door_motion_and_light. Unknown error for call_service at pos 2:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 434, in action
await script_obj.async_run(variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 162, in async_run
await self._handle_action(action, variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 246, in _handle_action
await self._actions[_determine_action(action)](action, variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 329, in _async_call_service
context=context,
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 98, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context
File "/usr/src/homeassistant/homeassistant/core.py", line 1234, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1259, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 139, in service_handler
if script.is_on:
AttributeError: 'NoneType' object has no attribute 'is_on'
As I can see, this script works just fine:
'1536739675112':
alias: Bath wait for humidity then off (night)
sequence:
- delay: 0:0:1
- condition: state
entity_id: binary_sensor.door_window_sensor_158d0001e5d691
state: 'on'
- data:
entity_id: switch.wall_switch_right_158d000245c5ca
service: switch.turn_off