Sensor activated only when binary_sensor is "On"

Good morning,

I would like to be able to change the state of a sensor only if a binari-sensor replies to pinging.

Basically, I would like to monitor the status of various processes on a remote computer but only when it responds to the ping.

I have a binary_senor to ping the pc (binary_sensor.pc):

  • platform: ping
    host: IP
    count: 2
    name: PC
    icon: ‘mdi:desktop-classic’
    scan_interval: 350

A sensor that recovers the state of the process (sensor.proc_status):

  • platform: command_line
    command: curl -X GET ‘http://IP:PORT/api/2/processlist/name/proc.exe’
    value_template: ‘{{ value_json[“proc.exe”][0][“status”] }}’
    name: Proc status
    scan_interval: 350

My question is, how do I get the sensor to activate only when the binary_sensor is on “On”?

And in the best of worlds, that the result obtained by the sensor activates a switch.:sunglasses:

Thank you for your help.

You could use a template sensor and use {% if ... %}, {% else %}, {% endif %} expressions for the value_template: attribute.


Ok i will test