I have an automation that when triggered calls a shell command, passing the new value of the sensor. Nine out of ten times this works, but occasionally the shell command, instead of sending a temperature, sends the string ‘unavailable’. Is there anyway I can put a conditional in the HA shell command, so it does nothing rather that sending unavailable?
This is the automation:
- id: Relay Greenhouse Temperature
alias: Relay Greenhouse Temperature
description: Send greenhouse temperature onto Weewx via Netlink
trigger:
- platform: state
entity_id: sensor.propagator_temperature
condition:
- condition: numeric_state
entity_id: sensor.propagator_temperature
above: '-5'
below: '50'
action:
- service: shell_command.send_netlink
data:
key: extraTemp1
value: '{{ trigger.to_state.state }}'
And this is the shell command.
shell_command:
send_netlink: /bin/bash -c "echo -e {{ key }}:{{ value }}':' | nc 192.168.98.10 2029"