jriker1
(John)
January 25, 2020, 1:12am
1
I have a result that comes in from SNMP
iso.3.6.1.2.1.25.3.5.1.2.1 = Hex-STRING: 00
with platform: snmp
When I try:
value_template: “{%if value == ‘0’ %}OK{% else %}Failed{% endif %}”
or
value_template: “{%if value == ‘00’ %}OK{% else %}Failed{% endif %}”
It returns Failed any idea what I’m doing wrong?
Your syntax is a bit off. Here is one I use:
- platform: snmp
name: 'Battery Status'
host: 192.168.30.151
baseoid: 1.3.6.1.4.1.318.1.1.1.2.2.4.0
community: 'public'
version: '2c'
scan_interval: 60
value_template: >-
{%- if 1 -%}
OK
{%- elif 2 -%}
Replace
{%- else -%}
N/A
{%- endif -%}
jriker1
(John)
January 25, 2020, 2:23pm
3
I was having a problem with the value_template as the return value of 00 was hex and wasn’t showing up in results. I did this that seems to work but not sure if it’s the right way.
value_template: "{%if value|int(base=16) == 0 %}OK{% else %}Failed{% endif %}"
Also what does the “>-” do with the value_template? Always see that but never know what it’s doing.
Thanks.
jriker1
(John)
January 25, 2020, 4:41pm
4
Also posted this new, but looks like SNMP or a number of sensors based on, may have blown up my system.
So I was posting a bunch of items that I was recently having issues with. I was getting a lot of warnings about SNMP taking more than 10 seconds to load but then other things started to happen like.
After my last reboot of HA noticed in the logs that metno isn’t working anymore
2020-01-25 10:10:20 ERROR (MainThread) [metno] https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/ returned
Not sure what I’m seeing is the full command but still erroring during startup.
Then als…