(SOLVED) Variables and templates

EDIT: Did a test and this is working… :slight_smile:

Hi There,

Will this work? I can try it but not at home at the moment…

  variables:
    season: sensor.season
    kay_learning: switch.kay_learning
    peter_early_up: switch.peter_early_up
    guests: switch.scene_guests
    motion_toilet: binary_sensor.pir_motion_sensor_with_temperature_sensor_detection
    motion_bedroom: binary_sensor.pir_motion_sensor_with_temperature_sensor_detection_5
    sensor_bedroom: binary_sensor.door_bedroom_contact
    adaptive: "{{ states('sensor.adaptive_lighting_color_temperature') }}"
    bedroom_brightness: >
      {% if is_state(peter_early_up, 'on') %} 0
      {% elif is_state(motion_bedroom, 'on') and is_state(sensor_bedroom, 'on') and (is_state(season, 'autumn') or is_state(season, 'winter')) %} 100
      {% elif is_state(motion_bedroom, 'on') and is_state(sensor_bedroom, 'on') and (is_state(season, 'spring') or is_state(season, 'summer')) %} 70
      {% else %} 100
      {% endif %}

Where are the variables motion_bedroom and sensor_bedroom defined? I assume elsewhere given that this appears to be a fragment of something bigger.

Sorry it was a part of the code. I will make it complete so everybody understand it.

If you wish, you can condense the template’s logic a bit:

    bedroom_brightness: >
      {% if is_state(peter_early_up, 'on') %} 0
      {% elif is_state(motion_bedroom, 'on') and is_state(sensor_bedroom, 'on') %}
        {{ 100 if states(season) in ['autumn', 'winter'] else 70 }}
      {% else %} 100
      {% endif %}
1 Like

Thanks for the info… Always good to learn!