Another: int got invalid input (but i has value!)

Hi, i’m new to this forum, but i used it to find solutions already :).
But i can’t find answer to my issue.

I had integrated openwrt to HA via collectd and mqtt, values are coming properly (checked via mqtt browser in HA) but my value for template returns error:

ValueError: Template error: int got invalid input '41800000' when rendering template '{{ value.split(':')[1] | int }}' but no default was specified rendering template for entity 'sensor.linksys_mr8300_linksys_gora_cyphered_2_4g_bitrate', template: '{{ value.split(':')[1] | int }}', default value: default and payload: 1730819543.628:41800000

My template is as follows:

         - name: linksys-gora Cyphered 2.4G Bitrate
          state_topic: homeassistant/linksys-gora/iwinfo-phy1-ap0/bitrate
          unit_of_measurement: Mbits
          value_template: "{{ value.split(':')[1] | int }}"
          unique_id: linksys-gora-iwinfo-phy1-bitrate
          device:
              identifiers: MR8300
              name: Linksys MR8300
              model: Linksys MR8300 (Dallas)
              manufacturer: Linksys

Default value for int didn’t solve issue - i can’t figure it out how to do it.
In template editor it works - but when i put it to config.yaml it doesn’t.

Can you please use MQTT Explorer (or similar) to copy the message from the topic in the broker and paste it into the forum as formatted text.

Payload:

Message 323 received on homeassistant/linksys-gora/iwinfo-phy1-ap0/bitrate at 08:30:
1730878223.627:37600000

I wonder if there’s an odd unprinted character in there? Try:

value_template: "{{ (value.split(':')[1]|select('in','0123456789')|join)|int(0) }}"
1 Like

Bingo! Damn :smiley:

fixed thx to you:

value_template: "{{ value.split(':')[1].split('\x00')[0] | int }}"