Hi There,
I am trying to create an automation / script that:
If the door sensor state is closed, Turn on the light if the humidity rises 2% or more within 3 minutes if fan (light) is already on, keep on while humidity is higher than 80% but not exceeding 1h off running time. if the fan (light) is on for 1 hour, it will sleep for 1 hour before turning it on again.
also, it will turn on the fan (light) for 10 minutes if the door sensor is closed for 5 minutes even if the humidity doesn’t change
This automation will never excide the fan (light) run time more than 1 hour
- apologies my fan entity is set as “light”
I keep getting the error below, and not sure why. can someone please help?
Message malformed: Unable to determine action @ data[‘action’][0]
Automation:
description: "Guest Bathroom"
mode: single
# Define a timer helper to manage timing conditions
- alias: "Control Light based on Humidity and Door Sensor"
trigger:
platform: state
entity_id: binary_sensor.sonoff_a440020f37
to: "on" # Trigger when the door sensor state is "on" (closed)
action:
- service: script.control_light_based_on_humidity_and_door_sensor
- alias: "Turn On Light when Humidity Rises"
trigger:
platform: numeric_state
entity_id: sensor.sonoff_a440024468_humidity
above: 80
for: "00:03:00"
condition:
- condition: state
entity_id: binary_sensor.sonoff_a440020f37
state: "on"
action:
- service: script.turn_on_light_when_humidity_rises
- alias: "Turn Off Light after 1 Hour"
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.timer
action:
- service: switch.turn_off
entity_id: switch.light.sonoff_a4400243d5
- alias: "Sleep for 1 Hour after Turning Off Light"
trigger:
platform: state
entity_id: switch.light.sonoff_a4400243d5
to: "off"
for: "01:00:00"
action:
- service: timer.start
data:
entity_id: timer.timer
- alias: "Turn On Light for 10 Minutes when Door Closed for 5 Minutes"
trigger:
platform: state
entity_id: binary_sensor.sonoff_a440020f37
to: "on"
for: "00:05:00"
action:
- service: script.turn_on_light_for_10_minutes_when_door_closed_for_5_minutes
Script:
script:
control_light_based_on_humidity_and_door_sensor:
sequence:
- condition: numeric_state
entity_id: sensor.sonoff_a440024468_humidity
above: 80
- service: switch.turn_on
entity_id: switch.light.sonoff_a4400243d5
- delay: '00:10:00'
- service: switch.turn_off
entity_id: switch.light.sonoff_a4400243d5
turn_on_light_when_humidity_rises:
sequence:
- condition: state
entity_id: binary_sensor.sonoff_a440020f37
state: "on"
- service: switch.turn_on
entity_id: switch.light.sonoff_a4400243d5
- service: timer.start
data:
entity_id: timer.timer
turn_on_light_for_10_minutes_when_door_closed_for_5_minutes:
sequence:
- service: switch.turn_on
entity_id: switch.light.sonoff_a4400243d5
- delay: '00:10:00'
- service: switch.turn_off
entity_id: switch.light.sonoff_a4400243d5