How can i make Auto Entities have a Press/Toggle To Restart Devices Press

so i tried googling and the AI google came up with some different codes but none work

it seems the Tplink devices i have to Restart are a Press not a Toggle… and the Auto enttites can do a Toggle switch at the top but not for Press

type: custom:auto-entities
card:
  type: entities
  title: TP Link - Restart
  show_header_toggle: true
filter:
  include:
    - options: {}
      device_manufacturer: TP-Link
      name: "*Restart*"
  exclude: []

these just some of the tp link devices but i wanna be able to restart them all at once

is my current code i like to be able to do is auto entites have a Press or Toggle… that will Restart all the entites it finds for the tplink and Restart

but so far i havent found how to do it… is it possible or no you can only toggle lights on or off

or is there a script that can take the auto entities and restart them if you cant have it in the header

Just to be clear. You want one button to restart all of the devices?

What does this give you:

{{ integration_entities("tplink") }}

@Hellis81
ya so i have multiple devices like shelly or reolink cameras and they all button press’s but the auto entities doesnt offer a toggle or a press in the header to reboot all the entities generated in the auto entities display… so if i wanted to do all words “restart” then the toggle or press would hit those buttons like it does for toggle restart like ESP home devices

but if there isnt a way to do it then a script that generates the the auto entities in a script and restarts them all

and i not sure where to put that code i did for entity_id and name but it comes up blank

filter:
  include:
    - options: {}
      device_manufacturer: TP-Link
      entity_id: {{ integration_entities("tplink") }}


filter:
  include:
    - options: {}
      device_manufacturer: TP-Link
      name: {{ integration_entities("tplink") }}

so not sure where i put it

I meant in developer tools → templates

@Hellis81

{{ integration_entities("tplink") }}

ok if i did that that the template it generates all the entities i guess

so since i cant copy and paste it un hightlights intstantly

one is

'button.garage_backdoor_light_restart', 

so here is a small screen capture

That’s good…

now let’s try this:

{{ integration_entities("tplink") |select('match','button\..*restart')|list }}

Make sure we only get the button entities and only the restart buttons you want.
We don’t want it to press a wrong button

ok so that template is working

Ok…
Then create a script with this sequence:

  - repeat:
      for_each: >-
        {{ integration_entities("tplink") |select('match','button\..*restart')|list }}
      sequence:
        - action: button.press
          metadata: {}
          data: {}
          target:
            entity_id: "{{ repeat.item }}"
        - delay:
            seconds: 2

so that code isnt working i tried to do it how the default starts off with sequence but it also gives me error
it didnt like repeat to start first

sequence:
  - action: button.press
    metadata: {}
    data: {}
    target:
      entity_id: "{{ repeat.item }}"
  - delay:
      seconds: 2
  - repeat:
      for_each: >-
        {{ integration_entities("tplink")
        |select('match','button\..*restart')|list }}

Well that code will never work.
You first need to get the entities then loop and press.

But this is what I meant it should look like:

sequence:
  - repeat:
      for_each: >-
        {{ integration_entities("tplink")
        |select('match','button\..*restart')|list }}
      sequence:
        - action: button.press
          metadata: {}
          data: {}
          target:
            entity_id: "{{ repeat.item }}"
        - delay:
            seconds: 2

ok that seems to be working i did get an error but i couldnt copy it or screen capature fast enough saying failed something something devices like where you see “message mailformed”

but it seems to work so it takes 1 entity restarts waits 2 seconds then goes to the 2nd one
is how i take it works

i was able to make it work for my ReoLink Cameras worked easy no more single pressing anymore

so question how do you learn this

      for_each: >-
        {{ integration_entities("tplink")
        |select('match','button\..*restart')|list }}

is this specfic to home assistant programmers that know all that… or is it like learning SQL or a different programming… it seems like SQL but i learned that 30 years but didnt never needed it in everyday life programming in Visual Basic as much later on…

so always willing to learn new things

Yes… we try to keep it a secret but someone posted it in the documentations.
Templating - Home Assistant

The big issue is knowing what the exact spelling is of the integration.
That I’m not sure how to find.

You can probably find it in the trace what the error is. Make sure you have it set to continue on error to make sure it doesn’t give up.

@Hellis81 ok ill try to remember the templating page and such i thought it was like sql days when reading info from a table but i stopped programming like 10 years ago on a regular basis

so thats cool the trace shows the steps i see the one trace is all blank thats where i guess the script “failed” as step details trace timeline releated activity script config are all blank. but the previous and after executing same script work fine

unless it failed if i re ran the script if the first time wasnt done yet is that possible? where the script is running but it hasnt gone through all the devices and i hit run again?

I believe the standard setting for scripts are single, which should mean the one running has to finish first, any new runs are exited.

Not sure what happens if you save a script while it’s still running. I guess that could make it exit early.

Templating isn’t easy. My advice is to read the forum for templates and challenge yourself with questions that already have an answer.
How would you solve this template question, then you can always scroll down to get the “answer”.
It obviously takes time to learn it all, so don’t expect it to take just a few days.
I don’t think I’m good at it myself, but I know a few things that gets me where I need.

ah good to know ill try to remember that for the next template i need

i wish we had home assistant in the 90s when i tried to make electronic projects and assembly langauge plc IDE ports it wasnt as nice and my college dropped home automations in early 2000s as you could do what home assistant could do but you had to pay someone 2k or more to come in your home and program custom devices to work… and it was no where as cheap it is today…

learn something new everyday i appreciate the help (: