I have been having issues with my setup and was wondering if somebody could help me please.
Devices are Sonoff, Basic and T4EU1C light switches (number of them)
All of them have been Tasmotised to 8.3.1
Connected via MQTT to HA.
I have 2 sets of conditions. Lights ON/OFF when I am Home, & Lights ON/OFF when I am NOT Home.
Both options work fine independently.
What I want to do is, when I am away,
- Lights come on as programmed.
- Depending on what time I return, if any lights are on, they turn off.
- If any lights are scheduled to turn on, their automation stops from happening.
- Lights should work as I am home.
I have tried doing this but the automation doesn’t stop as I want. Script below turns the light on when no one is home.
- id: '1592821885507'
alias: 3020A - Ayesha Lamp Boolean ON/OFF when NO ONE is at Home
description: Turns Ayesha Lamp Boolean ON/OFF when NO ONE is at Home
trigger:
- event: sunset
offset: '1'
platform: sun
- entity_id: binary_sensor.somebody
for: 00:05:00
from: 'on'
platform: state
to: 'off'
condition:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.somebody
state: 'off'
- condition: state
entity_id: input_boolean.lamp_ayesha
state: 'off'
- after: '17:00:00'
before: '22:00:00'
condition: time
- after: sunset
after_offset: '1'
condition: sun
action:
- delay: 00:{{ '{:02}'.format(range(1,15) | random | int) }}:00
- data: {}
entity_id: input_boolean.lamp_ayesha
service: input_boolean.turn_on
- data:
message: Ayeshas Bedroom Lamp Boolean just changed to {{ (states('input_boolean.lamp_ayesha'))
}} when No One is at Home.
service: notify.mobile_app_iphone
mode: single
Script below stops the automation:
- id: '1595607660349'
alias: 4001 - Turn All Lights OFF when Arriving Home
description: ''
trigger:
- entity_id: binary_sensor.somebody
for: 00:01:00
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data: {}
entity_id: light.lamp_ayesha
service: homeassistant.turn_off
- data: {}
entity_id: light.lamp_divya
service: homeassistant.turn_off
- data: {}
entity_id: light.light_ayesha
service: homeassistant.turn_off
- data: {}
entity_id: light.light_bathroom
service: homeassistant.turn_off
- data: {}
entity_id: light.light_cloakroom
service: homeassistant.turn_off
- data: {}
entity_id: light.light_diningroom
service: homeassistant.turn_off
- data: {}
entity_id: light.light_divya
service: homeassistant.turn_off
- data: {}
entity_id: light.light_ensuite
service: homeassistant.turn_off
- data: {}
entity_id: light.light_lounge
service: homeassistant.turn_off
- data: {}
entity_id: light.light_mums
service: homeassistant.turn_off
- data: {}
entity_id: light.light_study
service: homeassistant.turn_off
- data: {}
entity_id: light.light_utility
service: homeassistant.turn_off
I hope the above two bits of code makes sense.