cancel
Showing results for 
Search instead for 
Did you mean: 

Check device current state

TwentyFour
Community Member

Hi,

Is there a way I can check the current state of a device?

The issue I have is I'm trying to create an automation that turns my light on 30min before sunset but only if my TV is switched on.  It only works if I remove the condition so must be some issue with that section, I've tried using my soundbar instead of the TV but I get the same result.

I'd like to see if I can find the TV or Soundbar current state to see if it is not showing correctly.

The code in case anyone wants to check is as follows:

starters:
    - type: time.schedule
           at: sunset-30min
      weekdays:
        - MON
        - TUE
        - WED
        - THU
        - FRI
        - SAT
        - SUN

  condition:
    type: device.state.OnOff
    state: on
    is: true
    device: Living Room TV - Living room

  actions:
    - type: device.command.OnOff
      on: true
      devices: Living room light - Living room

Thanks in advance.

2 REPLIES 2

Hollen_ar_mor
Community Member

Try to write "condition" & "action" with the same tabulation than "starters".

You have no error in the script editor ?

I didn't notice at the first reading, but your "time.schedule" syntax is wrong :

- type: time.schedule
  before: sunrise
  after: sunset+30min

 

There's an autotext in Automation normally. When you choose a "type", the fields to fill should appear automatically.