Unable to create working automation

Hi all,

For several weeks now i am trying to create an automation. But i am unable to get it working (status stays triggered: never)
The description of the automation i want to create:
i want my light to turn on at sunset, when i am or watching television of watching Netflix

Below the YAML i use:

- id: '1595275901827'
  alias: Automatisch licht inschakelen bij zonsondergang
  trigger:
  - platform: state
    entity_id: sun.sun
    from: above_horizon
    to: below_horizon
  condition:
  - condition: or
    conditions:
    - condition: template
      value_template: '{{ is_state_attr(''remote.woonkamer'',''activity'',''41789178'')
        }}'
    - condition: template
      value_template: '{{ is_state_attr(''remote.woonkamer'',''activity'',''6904096'')
        }}'
  action:
  - type: turn_on
    entity_id: light.shelly_shdm_1_d3f2f8
    device_id: d76e52793b8849ea90c7f35ac614d0dd
    domain: light
    brightness_pct: 40

i am pretty sure my fault is situated in the value template i use, but i am unable to find out what (syntax) error causes my automation not to run.

To make the info complete, i put the content i needed to write the template, below (this is the content found in my harmony_xxxxxxx.conf file)

"Activities": {
        "-1": "PowerOff",
        "20008854": "TV Keuken",
        "24288896": "Sonos Keuken",
        "24288909": "Sonos Woonkamer",
        "30016932": "BluRay Kijken",
        "39027824": "CD Luisteren",
        "39027830": "LP luisteren",
        "41789178": "Netflix kijken",
        "6904096": "TV kijken"
},

Can anyone help me to make clear what i did wrong whit my template syntax.

Sincerely,

Guy

When you’re watching television or Netflix, go to the template editor and enter the following:

{{ states.remote.woonkamer.attributes }}

Then copy and paste the results here.

Hi Phil,

please find the output here:

{'current_activity': 'TV kijken', 'friendly_name': 'Woonkamer', 'supported_features': 0}

Thanks,

Guy

Ok, then it looks like this should work for you:

  condition:
  - condition: template
    value_template: >
      {{ state_attr('remote.woonkamer', 'current_activity') in
         ['TV kijken', 'Netflix kijken'] }}

Hi Phil,

This is indeed the solution. I had to use the given name i provided for each activity in the harmony app, and now i also learned that i can combine multiple values! Works Fine now!

Thanks for the help :+1:

Guy

1 Like