Command line sensor with condition

How can i scan a command line sensor only when the device tracker status is not at home ?

for example :

sensor wasserdurchfluss:         
  - platform: command_line
    name: wasserdurchfluss
    command: curl -X POST -i 'http://192.168.2.9/mux_http' --data 'id=622&show=D_A_1_1~'
    scan_interval: 30
    value_template: "{{ value.split('<code>')[1].split('D_A_1_1>')[1] }}"

Set the scan_interval to something ridiculously long, then use the homeassistant.update_entity service (probably in an automation) when you want it to scan.

1 Like