Problem with automation based on time and state

Hello!
Trying to get this automation to work, what i want is that if the tv is on after 23 the light will keep beeing turned on until i turn off the tv then i want the automation to wait for 10 minutes then turn all off.
Automation created in front end:

id: '1600786229998'
alias: Belysning Uppe off 23 Vardag
description: ''
trigger:
  - platform: time
    at: '23:00'
condition:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - sun
  - condition: and
    conditions:
      - condition: state
        entity_id: binary_sensor.samsung_tv_status
        state: 'off'
        for: '00:10:00'
action:
  - scene: scene.5b_uppe_off
mode: single
max: 10

Your trigger only happens at 23:00, not after.
So it runs once at 23:00 and the condition of TV is on so it fails and gives up.

You will need a after:

trigger:
  platform: time
  after: "23:00"
  before: "02:00" # ???

You have your conditions and triggers back to front.

The trigger is the tv turning off.

The condition is that it has to be after 11pm for the actions to occur.

trigger:
  - platform: state
    entity_id: binary_sensor.samsung_tv_status
    to: off
    for:
      minutes: 10
condition:
  condition: time
  after: '23:00'
action:
  - scene: scene.5b_uppe_off

Yes, off course…

Thank you!!

Will this trigger at 11pm if tv is off?
If the tv is on att 11 will it trigger after 10 minutes when the tv is turned off after 11 before 3?

If you turn off the tv at 21:00 then the automation will turn off the lights at 23:00.
If you turn off the tv at 22:55 then the automation will turn off the lights at 23:05.
If you turn off the tv at 23:00 then the automation will turn off the lights at 23:10.

Nope not that one. it will only be 21:10 when the tv has been off for 10 minutes, which will not pass the after 11pm condition.

The others are correct.

No. Not unless you turned the tv off at 22:51.

Where did the before 3am requirement come from?

If you turn the TV off between 22:50 and midnight the lights will go off 10 minutes later.

the importance is:
a, if tv is off, the light will turn off att 11
b, if tv is on under/after 11 the light will stay on until i turn off tv and 10 minutes passes.
c, i want to be able to turn on and off tv until 11 without the lights turns off

(never mind the 3am)

Well that’s almost clearer than your original post. No idea what you mean by “under/after 11” though.

Assuming you mean after 11, try this:

trigger:
  - platform: time 
    at: '23:00'
  - platform: state  
    entity_id: binary_sensor.samsung_tv_status
    to: off
    for:
      minutes: 10
condition:
  - condition: time
     after: '23:00'
  - condition: state
    entity_id: binary_sensor.samsung_tv_status
    state: off
    for:
      minutes: 10
action:
  - scene: scene.5b_uppe_off

This will turn the lights off at 11pm if the tv is off. It will also nearly do your other option. The lights will turn off after 10 minutes if you turn off the tv after 22:50. If that bugs you the easiest way around this is to use two automations:

Automation for 11pm lights off if TV off:

trigger:
  - platform: time 
    at: '23:00'
condition:
  - condition: state
    entity_id: binary_sensor.samsung_tv_status
    state: off
action:
  - scene: scene.5b_uppe_off

Automation for lights off after 10 minutes if tv turned off after 11pm:

trigger:
  - platform: state  
    entity_id: binary_sensor.samsung_tv_status
    to: off
    for:
      minutes: 10
condition:
  - condition: time
     after: '23:10'
action:
  - scene: scene.5b_uppe_off

Tank you, it woked!!