I am using the [ping binary_sensor(https://www.home-assistant.io/integrations/ping/) but would like to be able to vary the interval. Most of the time it’s fine to check every 5 minutes (300) but when I perform certain actions I want to check as frequently as every second. I tried using a value_template in the scan interval
ERROR (MainThread) [homeassistant.config]
Invalid config for [binary_sensor]:
[value_template] is an invalid option for [binary_sensor].
Check: binary_sensor->scan_interval->value_template.
A similar question was asked here with no answer. This post seems to suggest that scan interval can have a value template under the command line platform. So I tried
[homeassistant.config]
Invalid config for [sensor]:
[value_template] is an invalid option for [sensor].
Check: sensor->scan_interval->value_template.
Could anybody suggest a way to have a ping run every second but just for a very limited time, to stop them swamping network traffic. How could I turn this on and off / enable or disable the sensor? Thanks
No you can’t template the scan interval. What you can do is set it to a very long time (years) and update it at varying rates using the update entity service in an automation.
That’s a good and workable solution @tom_l and gives me exactly what I was hoping for, I was going to be using it in automations, so it’s ideal. If you want to see the correct formatting in the solution check the link at the top of it.
See also the config files for a working solution using automations in this way in a UX for remote reboots
I’m still too little experienced in this stuff and also have my challenges in this field.
I see a problem: Automations need updated sensor values. But they start with a trigger followed by conditions followed by actions. How do you locate/execute an entity update between the trigger and the condition? I can add it as a part of the actions, but this is too late.
By the way: what happens if you set the scan interval to 0/zero?
You have one automation triggered by a variable time interval that updates the sensor in its actions. You can have another automation triggered by this sensor update.
I believe it falls back to the default polling interval of the sensor.
This appears to be rather complicated - two separate but timely dependent automations.
I performed a brief test and the following appears to work: I added the update to the action part, then opened automation.yaml and moved the action from the action code part between the trigger and the condition code part:
As I said initially: I am very new to HASS, YAML, PYTHON.
My assumption was that the YAML sequence is processed sequentially without any semantic check of the sequence as such, and the UI for editing automations only is something on top of it which does not cover such special cases as inserting actions before conditions.