I have an issue with a command line sensor wich should give the temperature of my espresso machine, wich was kindly shared by stangster in the kaffee-netz.de forum.
addendum:
Please note that I have been informed that the code was partially created using ChatGPT.
The quality and functionality are therefore questionable.
command_line:
- sensor:
name: "ito temperature"
command: >-
printf 'MC@\r\n' |
nc -w 3 192.168.2.67 23 |
tr -d '\r' | head -n 1 | sed -E 's/^<|>$//g' |
awk '
{
t=""; he="";
if (match($0, /:[[:space:]]*([0-9]+(\.[0-9]+)?)([[:space:]]*°)?/, m)) t=m[1];
if (match($0, /([0-9]+(\.[0-9]+)?)%/, h)) he=h[1];
}
END {
if (t=="" || he=="") exit 1; # keine Ausgabe -> unavailable
printf("{\"temp_c\":%s,\"heater_pct\":%s}\n", t, he);
}'
scan_interval: 10
command_timeout: 5
unit_of_measurement: "°C"
value_template: "{{ value_json.temp_c | float }}"
availability_template: "{{ value != '' }}"
json_attributes:
- heater_pct
I get this error in my log:
Invalid config for 'command_line' at configuration/command_line.yaml, line 27: 'availability_template' is an invalid option for 'command_line'
Can someone spot what’s wrong?
Assistance would be greatly appreciated.