So I had an automation that makes it so when I leave my room it turns off the lights and creates a scene and when I come back it used to activate that scene but recently it was still turning off the lights but it never turned them back on
I made the create scene separate because I thought it had to do with the problem but it didn’t work
#Espresense automation not working all of a sudden
1 messages · Page 1 of 1 (latest)
@wispy nest
Screen shots are ok but when it comes to seeing how the code flows it is time consuming and hard for many of us to understand or provide support.
Up the top right on your automation you should see Traces
This is a good place to start while debugging issues, you can look at your automation step by step, seeing where it goes, breaks or other.
This Traces also has the Automation config that's something you could share scan & remove any doxing info in any, unlikey unless you used devices with personal names by {foobar} .
Sharing this will for sure get you some assistance and render a solution, as someone here can copy & paste the code into there ha lab or visully trace.
On your splitting into 2, imo this should be a single Automation, so I would share what you tried on that one.
id: '1762131841816'
alias: left Instant
description: ''
triggers:
- entity_id:
- sensor.iphone_de_ca_bt
from: ca_bedroom
trigger: state
to: null
conditions:
- sensor.iphone_de_ca_bt
- condition: state
entity_id: input_boolean.dodo
state:- 'off'
- condition: switch.is_on
target:
entity_id: input_boolean.instant_switch
options:
behavior: any
for: '00:00:00'
actions: - action: timer.start
metadata: {}
target:
entity_id: timer.iphone_bt_come_back
data:
duration:
hours: 2
minutes: 0
seconds: 0 - delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 700 - type: turn_off
device_id: 0f4db2c095dd7cde175ce783474d1e35
entity_id: bc8f7245d4bacfc43ba41f648177cf33
domain: light - type: turn_off
device_id: 46c90d715391f332ae53df82f3478268
entity_id: 1f81e4f1ae81d9f8ff91c8d29fc2a50e
domain: light - type: turn_off
device_id: be000a70e30417b51f7af0a891a9b42a
entity_id: c05390685fb90ac61c3de8c0a563ed72
domain: light - type: turn_off
device_id: e0e3d326a715b00b4e5f6763082e6b5e
entity_id: 51dcc21e842eb3e9c759d90c3b290619
domain: fan
mode: single
i just dont understand why its not showing up in the code the create scene
hmm scene.create before you turn anything off would be the logical solution here. yes I think this the issue, so you snapshot after the lights are off it just restores the off state.
let me reword this better.
EXAMPLE: Below, is not the solution, it provides you the logic to whats going wrong. You'll need to cusomise to your install requirments
alias: Room - Leave & Return
triggers:
- trigger: state
entity_id: sensor.your_presence_sensor
from: your_room
to: null
id: left_room
- trigger: state
entity_id: sensor.your_presence_sensor
from: null
to: your_room
id: returned_room
actions:
- choose:
- conditions:
- condition: trigger
id: left_room
sequence:
- action: scene.create # Step 1 - save the lights
data:
scene_id: my_room_scene
snapshot_entities:
- light.your_light
- action: light.turn_off # Step 2 - turn off
target:
entity_id: light.your_light
- conditions:
- condition: trigger
id: returned_room
sequence:
- action: scene.turn_on # Step 3 - restore
target:
entity_id: scene.my_room_scene
So scene.create must always come before light.turn_off or you'll just save an off state!
- Swap out sensor.your_presence_sensor, your_room and light.your_light to your requirments.
IFyou want a working example let know, but I'll let you try to figure it out without a || spoiler || to the fun, but if its no longer fun then here to help.
Also:
Posting code in Discord 👇
Just wrap your code with triple backticks above and below:
```
your code goes here
```
Want it colourful and easier to read? Add the language after the first three backticks
(yaml, python, json, javascript, css, bash, diff, fix, apache, coffeescript, cpp, ini, php, & more):
```yaml
your code goes here
```
For a single line of code or snippet just use ` yourcode `
No I did that if you saw the screen recording you see the create scene and then 1s pause but I don’t know why it’s doesn’t show in the yaml code even if i did it in the visual editor just look at the screen recording
ok so i realized i did not see the create scene bc i moved it to the same automation and did not activate it so the traces did not update but now i just walked into my room it worked so
Oh cool, so its working now?....
yes
Ha ha nice.
My bad for wasting your time for a easy fix that could’ve been done way sooner