After some help with my automation

Hi all.
I’ve created a ‘bedtime’ automation and was hoping to add all the little bits into one automation a few separate ones.
So basically this is what I’m wanting to happen.

When I press my button at night I want it to turn some things off straight away and set the house alarm (through mqtt) but leave the Dining room lamp on until until the Living room door changes to closed and the alarm sensors state is also ‘Part Set’ (it takes about 10 seconds for my house alarm to set)

When I close the living room door the lamp should then go off if the alarm is set or wait until they both are.

Then I want it to wait 10 mins and when the power drops below 35w on my smart plug upstairs turn the plug off , so basically if I watch some TV in bed and put the TV box and TV onto standby.
I’ve tried all sorts of if conditions etc I just can’t get it to do that, it either doesn’t turn the lamp off or turns the lamp off when the a look arm sets even if the doors open.
This is my code thanks for any help.

alias: "Bedtime "
description: ""
triggers:
  - domain: mqtt
    device_id: c53751c9aefbf2790d22b6401aa47813
    type: action
    subtype: toggle
    trigger: device
    id: "1"
    alias: Ikea button pressed
conditions: []
actions:
  - parallel:
      - action: mqtt.publish
        metadata: {}
        data:
          evaluate_payload: false
          qos: "2"
          retain: false
          topic: selfmon/vmod.010faa/vkp/key
          payload: MYPAYLOAD
        alias: Set alarm
      - alias: Turn room lights off
        action: light.turn_off
        metadata: {}
        data: {}
        target:
          device_id:
            - e8c8e8c34ae24dfea8aea303fb5c670f
            - 46006cd0e908151971db1db52d88f1c5
          entity_id: light.outdoor_leds
      - action: media_player.toggle
        metadata: {}
        data: {}
        target:
          device_id: 168bd975df730dab0223ef13fbd983b4
          entity_id: media_player.octagon
        alias: Turn off tv and box
  - wait_for_trigger:
      - trigger: state
        entity_id:
          - binary_sensor.living_room_door_contact
        to: "off"
      - trigger: state
        entity_id:
          - sensor.flex_status
        to: Part Set
    timeout:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
  - delay:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
  - wait_for_trigger:
      - trigger: numeric_state
        entity_id:
          - sensor.bedroom_tv_power
        below: 35
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      device_id: 7767edb7d836ba25907e20299c59aa49
mode: single

Is there a reason for the second wait for trigger?

Watching TV in bed seems to be a separate activity from turning lights off and setting the alarm. I personally would put it in a separate automation.

The first wait for trigger doesn’t seem to do anything as you’ve got it after the set alarm, turn off outdoor lights and turn off TV actions. I think. :grin:

Hi @jackjourneyman yeah I thought about putting it in separate ones but thought it would be neater all together as it’s all bedtime related , but guess it’s probably best to split them :smile:
The first wait is waiting for the alarm sensor to change to Part Set and also the door to close.
So roughly leave the 1 lamp on until we leave the room and then turn it off so it’s not pitch black.
Thanks