Sensor for a running / not running automation

Hi there,
I have an automation running all night (turns on/off lights randomly) using the “repeat: while:” function. There is a way to have a sensor talling me that the automation is running? Automation state is “on” event if it is non runnng.
Thanks
Gekomax

Use the current attribute. If it’s greater than zero then it’s running.

Hi,
I am more interested in getting to know how you implemented the random on/off
of the lights, Would you mind sharing your code for this?

Thanks - Dave

Hi, thanks.
I’m trying this according your suggestion:

- platform: template
  sensors:
    simulatore_presenza_looper_parziale_stato:
      value_template: >
        {% if state_attr('automation.simulatore_presenza_looper_luci_tutta_la_casa', 'current') | float == 0 %}
          off
        {% else %}
          on
        {% endif %}
      icon_template: >
        {% if state_attr('automation.simulatore_presenza_looper_luci_tutta_la_casa', 'current') | float == 0 %}
          mdi:speedometer-slow
        {% else %}
          mdi:speedometer
        {% endif %}

Will see if it’s going to work.
Thanks
Gekomax

I need that sensor in order to do some tests then I’m going to post the entire work on “Share your Projects!” section.
I’ll let you know here too
Bye
Gekomax

That would be ok if you’re creating a sensor. But if you’re creating a binary_sensor, then:

- platform: template
  sensors:
    simulatore_presenza_looper_parziale_stato:
      value_template: >
        {{ state_attr('automation.simulatore_presenza_looper_luci_tutta_la_casa', 'current') > 0 }}
      icon_template: >
        {% if state_attr('automation.simulatore_presenza_looper_luci_tutta_la_casa', 'current') > 0 %}
          mdi:speedometer
        {% else %}
          mdi:speedometer-slow
        {% endif %}

BTW, no need for the float filter. The current attribute is already a number (i.e., not a string.)

thanks for your suggestions.
just one thing. Is there any difference between binary_sensor and sensor in terms of performace?
Goof day
Gekomax

Why would you care? Use what makes more sense. In this case, if it were me, I’d use a binary sensor.

I’ll do the same.
Thanks!
Gekomax

Hi there.
In case you are interested I shared my configuration here: Presence simulator (random turn on/off lights during the night)

Gekomax