How to use variable option in automation

Hello,

I have several sensors like this

- platform: history_stats
  name: "replay_lamp_milan"
  entity_id: switch.lamp_milan
  state: "on"
  type: count
  start: >
    {{ as_timestamp(now()) - (7*86400) }}

and for my automation, I would like to get the corresponding entity id.
I tried state_att, but the only available attributes are those

state_class: measurement
unit_of_measurement: ""
icon: mdi:chart-line
friendly_name: replay_lamp_milan

How can I get the rerelated entity_id without having to specify this separate.

Post, or at least describe, the automation. How are the History Stats sensors related to the automation?

Your desired output is the entity ID… what are the inputs?

1 Like

Actually I was trying to improve the vacation ligthing blueprint

at the moment I have 18 lights, and because of some renamings of entities I found that my config was broken.
and I thought it would be much simpler if I could improve one and onther.

So my input of the blueprint would be my history_stats

  input:
    vacation_mode_toggle:
      name: Vacation Mode - Input Boolean
      selector:
        entity:
          domain: input_boolean
    replay_sensors:
      name: replay_sensors
      description: replay_sensors
      selector:
        entity:
          domain:
            - sensor
          multiple: true

then depending on the selected stat, a light of switch should toggle.
the one related to entity_id
so my input would be: sensor.replay_lamp_milan and the result switch.lamp_milan
so something like this: {{ state_attr('sensor.replay_lamp_milan','entity_id') }}
but not state_atrr because that one doesn’t know entity_id