Hi all, I’ve a command_line script (platform: command_line) that make a picture from a webcam and returns a number to HA.
This picture is taken 4 times a day, in the same moment I need to turn on the light, which is the best automation I can use?
Depending on the latency of you light source and how quickly your camera can adjust exposure etc, you may need to add a short delay between the light.turn_on and calling the script.
Hi all, I’d go with tinkerer suggestion. I tried something similar before posting without success. The automation I created is below. test_p is the command_line script, at the moment return always a fixed number (1).
- id: '1634155094656'
alias: Test sensor read
description: ''
trigger:
- platform: state
entity_id: sensor.test_p
condition: []
action:
- service: switch.turn_on
data: {}
entity_id: switch.photo_light
mode: single
thanks for the answer,
the important point is that the light must be turned on before the script returns. it must be trigger as soon as the script is executed (it takes 10seconds). You will know that the number is changed only after the photo has been taken.
Not sure I understand. You run a script every x minutes and you’d want the light to turn on before?
In the automation that runs every x, just turn on the light before the script, then.
Hi Koying, the sensor has it’s own frequency and currently it isn’t controlled by an automation.
If I control it with an automation how I can disable the actual scan_interval?
In addition I don’t even know how to fire a Command line Sensor read from an automation as you suggest
There is command_line which is a sensor, so you’d need the value returned by the command. Apparently it’s not the case.
Then there is shell_command, which is a service that you can use in an automation, but for which you don’t need/care about the return value.
If you use that in an automation, you control the triggering with, e.g., a time pattern trigger, and you can turn on your light before, and even turn it off after, as the automation is blocked until the shell command has finished (iirc).
command_line sensors is the one I’m using but if I understood correctly I can’t sample it in an automation. shell_command can be sample in an automation but then how I can pass the result to HA?