#Automation TV

1 messages Β· Page 1 of 1 (latest)

limber geode
#

Is there a solution for "Automate" a certain task?
Like i had yesterday trying to automate my "tv lounge"

f.e.

tv is on and it gets 9pm -> lights 20% and so on??
if the tv gets turned on after 9pm it doesnt check this function how can i realise that?

Thanks!

currently its if tv for 2min off than turn lights off but yesterday it didnt worked

hard basin
#

Just add the turning on of the TV as trigger as well πŸ™‚ As triggers are just every possible moment you want to act. And as you clearly want something to possibly happen when you turn on the TV it should be a trigger.

Triggers:

  • 9 pm
  • TV turned on
    Conditions
  • After 9pm
  • TV is on
    Action
  • Lights to 20%

If you post complete yaml of automation is way easier to help. See #best-posting-practices message

limber geode
#

alias: TV Automation An/Aus
description: >-
  Schaltet Lichter an, wenn der Fernseher ab 17 Uhr eingeschaltet wird und
  wieder aus, wenn er ausgeschaltet wird.
triggers:
  - trigger: state
    entity_id:
      - remote.wohnzimmer_shield
    from: "off"
    to: "on"
conditions:
  - condition: time
    after: "16:59:59"
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: remote.wohnzimmer_shield
            state: "on"
            for:
              hours: 0
              minutes: 0
              seconds: 30
        sequence:
          - type: turn_on
            device_id: 33dc8726bc14581001455e0faeca46a5
            entity_id: 8781ce829cef438440100b8f6380e545
            domain: light
            brightness_pct: 50
            enabled: false
          - type: turn_on
            device_id: 7522931873358f705c5906819cf446ff
            entity_id: 25f5a65704ed4cfc5016d88187000867
            domain: light
            brightness_pct: 50
            enabled: false
          - action: light.turn_on
            metadata: {}
            data:
              brightness_pct: 50
              rgb_color:
                - 242
                - 192
                - 54
            target:
              entity_id:
                - light.couch
                - light.sideboard
        alias: TV an
      - conditions:
          - alias: Wenn TV 2min aus ist
            condition: state
            entity_id: remote.wohnzimmer_shield
            state: "off"
            for:
              hours: 0
              minutes: 2
              seconds: 0
        sequence:
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id:
                - light.couch
                - light.sideboard
        alias: TV aus
mode: single

hard basin
#

Please read the link I posted!

limber geode
#

so i currently have it configured that

if tv switches from on to off (counter 30sec)

and if the time is after 5pm

than choose from 2 possibilities

option1: TV on lights on 50%

option2: TV off lights off

limber geode
knotty sparrow
#

you need that as an additional trigger

#

and as @hard basin already mentioned you also need to add the time as the trigger, otherwise nothing will happen when the tv is already on at that time

#

if you want all of this to happen, you need 3 triggers:

  • tv turns on
  • tv turns off
  • time
limber geode
#

ahhh understood so i have to duplicate this and switch it from on to "off" ?

knotty sparrow
#

yes

limber geode
#

now i understand way better how HA works

#

big thanks to you guys ❀️

hard basin
#

Don't see a trigger as the moment something happens. See it as the moment something possibly should happen. Conditions sort when something should or should not happen,.

limber geode
#
alias: TV Automation An/Aus
description: >-
  Schaltet Lichter an, wenn der Fernseher ab 17 Uhr eingeschaltet wird und
  wieder aus, wenn er ausgeschaltet wird.
triggers:
  - trigger: state
    entity_id:
      - remote.wohnzimmer_shield
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 30
  - trigger: time
    at: "17:00:00"
  - trigger: state
    entity_id:
      - remote.wohnzimmer_shield
    for:
      hours: 0
      minutes: 2
      seconds: 0
    from: "on"
    to: "off"
conditions:
  - condition: time
    after: "17:00:00"
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: remote.wohnzimmer_shield
            state: "on"
            for:
              hours: 0
              minutes: 0
              seconds: 30
        sequence:
          - type: turn_on
            device_id: 33dc8726bc14581001455e0faeca46a5
            entity_id: 8781ce829cef438440100b8f6380e545
            domain: light
            brightness_pct: 50
            enabled: false
          - type: turn_on
            device_id: 7522931873358f705c5906819cf446ff
            entity_id: 25f5a65704ed4cfc5016d88187000867
            domain: light
            brightness_pct: 50
            enabled: false
          - action: light.turn_on
            metadata: {}
            data:
              brightness_pct: 50
              rgb_color:
                - 242
                - 192
                - 54
            target:
              entity_id:
                - light.couch
                - light.sideboard
        alias: TV an
      - conditions:
          - alias: Wenn TV aus
            condition: state
            entity_id: remote.wohnzimmer_shield
            state: "off"
        sequence:
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id:
                - light.couch
                - light.sideboard
        alias: TV aus
mode: single
#

this is now the updated one πŸ˜„

#

aus = off an = on

For clarification ^^

knotty sparrow
#

We're both Dutch, we can understand enough German to understand aus and an πŸ˜‰

limber geode
#

haha nice πŸ˜„

hard basin
#

Dutch, so German isn't a real problem.

But a note on this automation, if you turn off the TV after midnight, nothing wiill happen πŸ™‚

knotty sparrow
#

yep, i would move the time condition to the first choose block

limber geode
#

ΓΆhhh? ^^

#

im a bit confused where it has to be

knotty sparrow
#
conditions: []
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: remote.wohnzimmer_shield
            state: "on"
            for:
              hours: 0
              minutes: 0
              seconds: 30
          - condition: time
            after: "17:00:00"
limber geode
#

ahhh

and i just have to create another condition for after midnight?

knotty sparrow
#

No, for turning off the time condition is now not taken into account anymore

#

so it will always turn of those 2 lights when the tv is off for 2 minutes, regardless of the time

hard basin
#

Because after 17:00 has the implicit condition of befor 0:00. As time repeats every day the start of the day is an implicit boarder. Otherwise it would now also be after 17:00 as we passed 17:00 yesterday :p

limber geode
limber geode
hard basin
#

so you have to define when you want the light to turn off when you turn off the TV. So if the strips are only uded for the TV it would be fine to always turn them off when you turn off the TV, no matter what time.

hard basin
limber geode
hard basin
#

it's basically just like in spoken language. If you talk about "before 7:00" we also already imply it has to be today before 7:00 aka, after midnight

limber geode
#

ok so im getting confused now what ive to change lol

^^ a bit overwhelming to have to think about so "many" tasks lol

hard basin
#
alias: TV Automation An/Aus
description: >-
  Schaltet Lichter an, wenn der Fernseher ab 17 Uhr eingeschaltet wird und
  wieder aus, wenn er ausgeschaltet wird.
triggers:
  - trigger: state
    entity_id:
      - remote.wohnzimmer_shield
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 30
  - trigger: time
    at: "17:00:00"
  - trigger: state
    entity_id:
      - remote.wohnzimmer_shield
    for:
      hours: 0
      minutes: 2
      seconds: 0
    from: "on"
    to: "off"
conditions: []
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: remote.wohnzimmer_shield
            state: "on"
          - condition: time
            after: "17:00:00"
        sequence:
          - type: turn_on
            device_id: 33dc8726bc14581001455e0faeca46a5
[etc]
#

(I don't pay for Discord so I was not allowed to post the whole automation :|)

limber geode
#

me neither lol
Why can i post the whole thing lol

#

ahhh because i havent exceeded the limit

knotty sparrow
#

oh, expand is not working for me, normally it would be possible to just expand it

limber geode
#

i can

hard basin
#

PastBin ftw :p

knotty sparrow
#

for me as well now, it was becasue of some work plugin was activated

spare gyroBOT
#

Please use a code share site to share code or logs, for example:

Please don't use Pastebin, since it can randomly add spaces to the main view. Please also don't share text as images since it makes it harder for people to help you. Remember that others may have colour blindness, impaired vision, etc.

limber geode
knotty sparrow
#

This is what I suggested before to fix turning of the TV after midnight

#

but now in the whole automation

hard basin
# spare gyro

Ah, never saw that (as, the spaces). But yeah. many paste services

limber geode
#

so now only the midnight problem where my brains currently turns off how to setup xD

knotty sparrow
#

however, the indentation is messed up

knotty sparrow
limber geode
knotty sparrow
hard basin
#

For the turn off that is.. If you turn on the TV after midnight, nothing will happen.

#

(yeah, the two disabled items make it a bit longer then needed)

limber geode
#

i dont want that lighting is turned on after midnight
I will also try to implement "colour scheme?" like as an indication "Go to sleep you dumfuck" ^^

was thinking about turn lights to red at 12pm

knotty sparrow
#
alias: TV Automation An/Aus
description: >-
  Schaltet Lichter an, wenn der Fernseher ab 17 Uhr eingeschaltet wird und
  wieder aus, wenn er ausgeschaltet wird.
triggers:
  - trigger: state
    entity_id:
      - remote.wohnzimmer_shield
    from: "off"
    to: "on"
    for:
      seconds: 30
  - trigger: time
    at: "17:00:00"
  - trigger: state
    entity_id:
      - remote.wohnzimmer_shield
    for:
      minutes: 2
    from: "on"
    to: "off"
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: remote.wohnzimmer_shield
            state: "on"
            for:
              seconds: 30
          - condition: time
            after: "17:00:00"
        sequence:
          - action: light.turn_on
            data:
              brightness_pct: 50
              rgb_color:
                - 242
                - 192
                - 54
            target:
              entity_id:
                - light.couch
                - light.sideboard
        alias: TV an
      - conditions:
          - alias: Wenn TV aus
            condition: state
            entity_id: remote.wohnzimmer_shield
            state: "off"
        sequence:
          - action: light.turn_off
            target:
              entity_id:
                - light.couch
                - light.sideboard
        alias: TV aus
mode: single
#

cleaned up version (with fixed indentation)

hard basin
#

If you're fine that the light will turn on between 17:00 and 24:00, you don't need to do change anything. Just using after: "17:00:00" is enough, the befor 24:00 is implicitly there.

knotty sparrow
#

but yeah, if you turn on the tv after 17:00 00:00 it won't turn on the lights. I don't expect that to happen often, but it it is an issue, you could add a before: xx:xx parameter as well to the time trigger

limber geode
hard basin
limber geode
#

so as i understand correctly AFTER 0:00 it will do nothing with the lighting right?
Thats i think completly fine because its defintly pretty eye straining to have like 5% or 20% light after 0:00 lol

#

but actually currently a big thanks for the fixes youve done to my HA will let you know how this is working at the timeframes πŸ˜„

because chatgpt and i had a good conference about dimming the light after 9pm to 25% when tv on

and at 11pm to 10% when tv on

hope this works lol

hard basin
#

if you turn the TV on after 0:00, nothing will happen. But because we moved the time condition only to the "turn lights on" option instead of the whole automation, the lights will turn off when you turn off the tv all day long

limber geode
#

ahh now i understood that was my mistake of thinking properly πŸ˜„
Big thanks for that

knotty sparrow
limber geode
#

but thats no problem because i even only wanted it to be working from 5 - 12pm
maybe 30min longer and at 12pm led turns red as a "notification"

#

So understanding at 0:00 "nothing" will happen with the lights etc?
Thats as i want it for now

Really big thanks to you both guys amazing!

hard basin
#

0:00 isn't a trigger, so nothing will happen. Only because it's the implicit end of the time condition of the first option, after 0:00 (until 17:00) that condition will render false thus even when you turn on the TV it will not do anything.

limber geode
#

i think thats fine as i understand this

what i understand is

That only again on the next day the automation will rerender at 5pm right?

limber geode
#

Hi so somehow the Govee lights turn off???

#

but nothing is shown in the logbook

#

exactly after 10 minutes? lol

hard basin
#

Can you look at het logbook of the device or light entity itself?
Basically, when HA shows no reason it was not because of HA.

limber geode
limber geode
#

Why isnt he going into this option? do i miss something out?

limber geode
#

i dont see the error i just "copied" your beginning and just changed the time and placed another time in there
What am i not understanding/missing at the structure?

hard basin
#

Ah, because the options of a chooser are checkt in order. And only the first option that matches is execute. And when it's after 22:00 is is also after 17:00 thus the first option is executed πŸ˜„

Easiest option is to switch the options around. Because when it's 17:00 it's not after 22:00 yet. So start with the latest option (smallest time frame) and go earlier / wider.

limber geode
#

ahhhhh got it

smallest time frame is counting backwards? 24,23,22,21.... so on?

#

so in this order i should put it?

#

because HA reads from top to down and if the Top one already is TRUE than "why should i go deeper?"

hard basin
#

yeah, make the condition range larger with each option. As the "after 22:00" is fully in the range of "after 17:00"

limber geode
#

ahhhh now i start understanding it

#

emmm

#

weird

#

it works but
the "couch.light" is set to 50% which is wrong and the "couch.sideboard" is set to 25% which is right

#

ah now

#

ok

#

weird weird
Im getting used to it
Sorry for all the questions

hard basin
#

πŸ˜„

#

Don't see this as a HA understanding thing, it's just understanding logical flows, mutual exclusivity and implication πŸ˜„

limber geode
#

i think ill always have trouble with this because my mind is blocking possible solutions lol

limber geode
#

hi so its me... again... i think its a bit buggy or idk but only one light is set to 25% even if chatgpt also says the code is correct

the scene which i am using is somehow setting the lighting too? https://dpaste.org/yTi8Q

#

also what i can mention it is executing the 25% rule

#

i defintly think its the scene but how can i prevent it from adjusting the light?