I am trying to read an Axe Effect sensor in my very basic HA config using the standard ENTITY-SENSOR-MIB and should return an integer type. This is my configuration.yaml:
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor:
- platform: google_wifi
host: 192.168.0.1
name: "Google WiFi"
monitored_conditions:
- current_version
- new_version
- uptime
- last_restart
- local_ip
- status
- platform: snmp
host: 192.168.0.80
name: "axeeffect_temp"
version: '1'
community: 'public'
baseoid: 1.3.6.1.2.1.99.1.1.1.4.0
unit_of_measurement: 'Deg F'
# Conversion from C to F is (Degrees C * 9/5) + 32 = Degrees F
# Axe Effect reports in integer 1/100ths of a degree F so devide number fetched by 100 ro correct the decimal point
value_template: '{{ ((value * 9 / 5 ) + 32 ) }}'
The error I am getting is one that doesnât make sense to me. The only error thrown right away after re-reading the yaml files is:
SNMP error for OID .1.3.6.1.2.1: No Such Object currently exists at this OID
If I snmpget that OID object from the config file I get
SNMP need the exact leaf OID.
Branch OIDs will not work.
Other tools can extrapolate the leaf OID from the branch OID, if there is only one branch OID on each step to the leaf OID.
Thanks for responding so quickly. I am not sure what you mean. The 192.168.0.80 1.3.6.1.2.1.99.1.1.1.4.0 is the leaf OID (instance 0) from what I read in the MIB (though I am willing to be corrected). 1.3.6.1.2.1.99.1.1.1.4 is the entPhySensorValue final branch OID (at least as far as I read the entitySensorMIB. If I am not reading it right, can you point out what I should be putting for the OID? Sorry to be so dense, but I really find this confusing.
Wouldnât the SNMPwalk have noted that since it walks the tree to the leaves, then back-traces? The instance number at the end is a individual sensor measurement value. You can see that in the SNMPget I included. The numbers in the ASN.1 syntax arenât âjust arbitrary numbersâ. They are structured âaddressesâ that map back to the structure defined in the MIB (and inspection shows there are no further branch nodes out further in the MIB on that .4 branch, just sensor instance leaves).
I know that it is structured âaddressesâ, but it does not map back to the MIB.
The MIB maps the part of the SNMP structure that it have information about in a human readable form.
The SNMP structure works fine without the MIB, al though it can be hard to read for us humans.
I do not remember how snmpget and snmpwalk output its values, but it is the last leaf/branch that always trips this up, since HA is very strict with that structured âaddressâ.
Try to remove the last .0 to see if that is the issue.
I personally use a Windows SNMP browser from iReasoning to do the SNMP looks up.
I appreciate the correction to the value_template. I applied that with no problem, but it didnât change anything of note. The change to the unit_of_measurement created a problem where HA would not start afterward. I seem unable to get that degree character in there. It always seems to be replaced by a dot. I finally sshâed in from another host to make sure it wasnât just the HA web gui, and adding it from there appeared to place a unicode character in there. HA would restart in recovery mode until I removed that character. I removed it and got it to come back by deleting that one character. I finally used the windows Charmap app to get the seemingly correct one in, and HA at least starts. The error block I get now is:
Logger: homeassistant.helpers.entity
Source: helpers/entity.py:960
First occurred: 9:32:40 AM (2 occurrences)
Last logged: 9:32:50 AM
Update for sensor.axeeffect_temp fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1318, in async_device_update
await self.async_update()
File "/usr/src/homeassistant/homeassistant/components/snmp/sensor.py", line 214, in async_update
value = self._value_template.async_render_with_possible_json_value(
value, STATE_UNKNOWN
)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 817, in async_render_with_possible_json_value
render_result = _render_with_context(
~~~~~~~~~~~~~~~~~~~~^
self.template, compiled, **variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
).strip()
^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2904, in _render_with_context
return template.render(**kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 1295, in render
self.environment.handle_exception()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 942, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
TypeError: unsupported operand type(s) for /: 'str' and 'int'
If you need the config again, it is:
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor:
- platform: google_wifi
host: 192.168.0.1
name: "Google WiFi"
monitored_conditions:
- current_version
- new_version
- uptime
- last_restart
- local_ip
- status
# Conversion from C to F is (Degrees C * 9/5) + 32 = Degrees F
# Axe Effect reports in integer 1/100ths of a degree F so devide number fetched by 100 ro correct the decimal point
- platform: snmp
host: 192.168.0.80
name: "axeeffect_temp"
version: '2c'
community: 'public'
baseoid: 1.3.6.1.2.1.99.1.1.1.4.0
unit_of_measurement: '°F'
value_template: '{{ ( 9 * value / 500 ) + 32 }}'
After changing, it still fails. The error message appears to be the same:
Logger: homeassistant.helpers.entity
Source: helpers/entity.py:960
First occurred: 9:32:40 AM (952 occurrences)
Last logged: 12:11:11 PM
Update for sensor.axeeffect_temp fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1318, in async_device_update
await self.async_update()
File "/usr/src/homeassistant/homeassistant/components/snmp/sensor.py", line 214, in async_update
value = self._value_template.async_render_with_possible_json_value(
value, STATE_UNKNOWN
)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 817, in async_render_with_possible_json_value
render_result = _render_with_context(
~~~~~~~~~~~~~~~~~~~~^
self.template, compiled, **variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
).strip()
^
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2904, in _render_with_context
return template.render(**kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 1295, in render
self.environment.handle_exception()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/jinja2/environment.py", line 942, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
TypeError: unsupported operand type(s) for /: 'str' and 'int'
That last line of the error implies that value is an INT instead of a floating point. Does the code cast it to an INT regardless of the type it was received as?
I restarted the whole HA instance and now it is working. I think it was the ( value | float ) change that got the data to display and the errrors to finally quit, but since I didnât do a complete restart until this change, I am not positive. The final working configuration.yaml is:
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor:
- platform: google_wifi
host: 192.168.0.1
name: "Google WiFi"
monitored_conditions:
- current_version
- new_version
- uptime
- last_restart
- local_ip
- status
# Conversion from C to F is (Degrees C * 9/5) + 32 = Degrees F
# Axe Effect reports in integer 1/100ths of a degree F so devide number fetched by 100 ro correct the decimal point
- platform: snmp
host: 192.168.0.80
name: "axeeffect_temp"
version: '2c'
community: 'public'
baseoid: 1.3.6.1.2.1.99.1.1.1.4.0
unit_of_measurement: '°F'
value_template: '{{ ( 9 * ( value | float ) / 500 ) + 32 }}'
Everything in HA is stored as strings, so casts to int or float is often a requirement, but maybe your value is not even a number.
Try to remove the value_template for now and just get the raw result.
I commented out the value template line and it just reported that my office was 2210 degrees C, but it didnât error out. I have discovered that to really see the change here you have to restart the HA instance, not just re-read the yaml files.
That might be one of those integrations that needs a complete reload.
I switched to Node Red for handling my SNMP, since I had to do some advanced calculations that was not easily done in HA.
As far as I understand it the value variable is typed (i.e. it is not always a string) however it depends on how your data is presented to the variable, e.g. â25â will show as a string, 25 will be a number.
Though this tends to suggest otherwise:
So maybe that is just for the value_json variable.
The failure to restart was definitely an issue. You must restart Home Assistant after you use any integration for the first time in YAML. If the integration supports a unique id and you give it one then any subsequent additions of that integration can be loaded with just a yaml reload.