weltmeyer / ha_snmp_stats

GNU General Public License v3.0
12 stars 9 forks source link

Values are not numbers? #12

Open RoganDawes opened 1 year ago

RoganDawes commented 1 year ago

Hi,

I have installed this integration, but I appear to be getting non-numeric values as results, judging by the history "graphs" for the entities. See example screenshot:

image

I would expect a History graph to show a line graph if the entities were numeric, and a state change sequence for a string or other attribute type?

As an additional evidence in support of the "incorrect type" theory, I present the following template:

The br_wan_total_in_byte is {{ states('sensor.snmp_stats_192_168_201_1_netif_br_wan_total_in_byte')  |int() | tojson() }}.
The br_wan_total_out_byte is {{ states('sensor.snmp_stats_192_168_201_1_netif_br_wan_total_out_byte')  | tojson() }}.
The br_wan_curbw_in_mbyte is {{ states('sensor.snmp_stats_192_168_201_1_netif_br_wan_curbw_in_mbyte') | tojson() }}.

which results in:

The br_wan_total_in_byte is 73566861632.
The br_wan_total_out_byte is "7701593540".
The br_wan_curbw_in_mbyte is "0.0".

Note that the first entry which is converted to an int is not quoted when converted to JSON, but the remaining two are quoted, suggesting that they are of string type. (I couldn't figure out how to evaluate the type of the entity directly, so figured that was a reasonable proxy.)

EDIT: Better test:

The br_wan_total_out_byte is {{ states('sensor.snmp_stats_192_168_201_1_netif_br_wan_total_out_byte') is string() }}.

returns True.