Query Scene parameters?

Question:
Is it possible inside of a template to query for the value of entities in a scene?

Goal:
At sunset, turn on the light to 45% brightness unless it is already on.

How I am trying to do this:
In an automation, set the brightness value of light.dining_room_chandelier to the brightness value defined for that light in scene.sunset if the light is currently off. If the light is currently on, do nothing.

Obviously I could ignore the scene altogether and just configure the automation to conditionally set the brightness value of the light based on it’s current state.

1 Like

I’m also trying to figure out the same thing.

When I look at the scene states the attributes are not defined. One can of course check whether the lights are within the parameters you defined when you set the state but that requires hardcoding the values in the template instead of having the template query the scene for these numbers:

- binary_sensor:
    - name: "Master Medium Active"
      unique_id: master_medium_active
      device_class: light
      state: >
        {% set lamp_off = is_state('switch.master_standing_lamp', 'off') %}
        {% set dimmer_on = is_state('light.master_dimmer', 'on') %}
        {% set dimmer_brightness = state_attr('light.master_dimmer', 'brightness') %}
        {% set dimmer_in_range = dimmer_brightness is not none and 179 <= dimmer_brightness <= 204 %}
        {{ 'on' if lamp_off and dimmer_on and dimmer_in_range else 'off' }}
      icon: >
        {% set lamp_off = is_state('switch.master_standing_lamp', 'off') %}
        {% set dimmer_on = is_state('light.master_dimmer', 'on') %}
        {% set dimmer_brightness = state_attr('light.master_dimmer', 'brightness') %}
        {% set dimmer_in_range = dimmer_brightness is not none and 179 <= dimmer_brightness <= 204 %}
        {% if lamp_off and dimmer_on and dimmer_in_range %}
          mdi:lightbulb-on
        {% else %}
          mdi:lightbulb-off
        {% endif %}

If anyone knows how to get these parameters from the scene please let us know.

just found this…might be worth a look. https://github.com/hugobloem/stateful_scenes