If no ping response, continue to shutdown servers

Hi all,

I have the following code:

  - platform: template
    switches:
      computers:
        turn_on:
          service: switch.turn_on
          data:
            entity_id: 
              - switch.micropc
              - switch.nas1
              - switch.nas3
              - switch.nas4
              - switch.nas5
              - switch.esxi1
              - switch.esxi2
        turn_off:
          service: switch.turn_off
          data:
            entity_id: 
              - switch.micropc
              - switch.nas1
              - switch.nas2
              - switch.nas3
              - switch.nas5
              - switch.esxi1
              - switch.esxi2

I would like the esxi servers to fully shutdown prior to the storage devices. I could add delays into the code but I would prefer it being based on no ping response.

Any help would be greatly appreciated, thank you.

Boyd

That would be an automation or script using a wait_template.

Could you give me an example?
Thank you

wait_template: "{{ states.binary_sensor.ping_server_one.state == 'off' and states.binary_sensor.ping_server_two.state == 'off' }}"

You would also need to split the switches so you have one for the servers and one for the storage devices, and if you don’t already have them, set up binary sensors for the server pings.

Your script would be in the order:

-switch off servers
-wait_template
-switch off storage

I’m so sorry for not getting back to you sooner. I got tied up with work and never checked back, I do apologise.

Thank you so much for explaining. I’ll put it into action and hopefully I’ll get it right!

Thanks again.
Boyd

1 Like

All good !
Everyone runs to their own schedules :wink: