Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106474

Command line sensor when command gives an error

$
0
0

Hi,
I have this sensor:

  - platform: command_line
    name: "Pressure"
    command: /config/packages/modpoll -t4 -r 12 -o 5 -i -c 1 -1 192.168.1.199 | grep '^\['
    value_template: "{{ ((value.split()[1] | float) / 10) | round(1) }}"
    scan_interval: 30
    unique_id: pressure
    unit_of_measurement: bar

Modpoll is a binary used to get register data from a modbus device. (I don’t want to use stock modbus sensor integration of HA)

When the device 192.168.1.199 is on line, everything works.
When the device is offline, the sensor freezes and stay with last recognized value.

I need to handle this event.

  • When the device is offline (and so, when command line gives an error) pressure sensor must be 0 bar.
  • When the device is online the value must be read from command line.

Unfortunately I cannot act on value_template, becuase the value has no state, when the device is offline.

Any idea?

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 106474

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>