Is there any way to check if a device is active on my network when an automation that includes it is run, and to skip that portion of the automation it if it’s not there.
I have several devices that aren’t always in range, and it’s filling my log file up with error messages.
Make the sensor and then see what state it has when there is no response from the device.
Then check for that state in your automation.
I know there is a ping sensor available, but I use one made in Node Red, so I do not know what states the one in HA has.
That shouldn’t be necessary. A state condition will do.
if you put that action at the end of your actions you can use an in-line condition:
action:
- service: ...
- service: ...
- service: ...
- condition: not
conditions:
- condition: state
entity_id: switch.foobar
state:
- unavailable
- unknown
- service: ... # this and actions below will not run if condition is false.
You can simplify the condition with a template condition and if the action needs to be in the middle of a list of actions you can use an if or choose action to check if the action should be run.
action:
- service: ...
- service: ...
- service: ...
- if:
- "{{ has_value('switch.foobar') }}"
then:
- service: ... # this will not run if the switch is unknown or unavailable
- service: ... # these continue to be executed
- service: ...
- service: ...
If all the services should not be run, put the condition in the main conditions block.
I’ve been using the GUI to set up HA, so I’m not really familiar with YAML, where these things actually need to go, or what to put in place of the placeholders.