Fritz router shows negative values for download?

Hi all

I have the fritz.box integrated here, but for some reason it shows negative values.
I can’t figure out the pattern, because it’s not because it’s positive numbers in one direction, and negative in the other, but it shows both positive and negative values for each direction.
negative_values

Does it show that in UPnP integration?

For me, this is happening during the daily forced disconnect of the ISP.

Mitigation:

      download:
        value_template: >
          {% set rate = state_attr('sensor.fritzbox', 'transmission_rate_down')|int(0) %}
          {% if rate < 0 %}
            0.00
          {% else %}
            {{ ((rate | float * 1 / 125000 )) | round(2) }}
          {% endif %}    
        friendly_name: 'Download'
        unit_of_measurement: 'Mbit/s'
      upload:
        value_template: >
          {% set rate = state_attr('sensor.fritzbox', 'transmission_rate_up')|int(0) %}
          {% if rate < 0 %}
            0.00
          {% else %}
            {{ ((rate | float * 1 / 125000 )) | round(2) }}
          {% endif %}    
        friendly_name: 'Upload'
        unit_of_measurement: 'Mbit/s'

@DavidFW1960 Yes, it’s the UPnP integration.

fritzbox:
  devices:
    - host: IP
      username: !secret fritz_user
      password: !secret fritz_pass

The sensors are called:

sensor.fritz_box_7560_kbyte_sec_received
sensor.fritz_box_7560_kbyte_sec_sent

@hsepm I don’t think I have a daily disconnect on my fiber connection, I should get a mail every time it is disconnected and get’s an IP.

Hi Holger,

I have the same problem, could you please tell me where to put that snippet of code?

Thanks in advance

… never mind, I figured it out.
Sorry, I am new to the project but already loving it. Yaml is not yet my friend :wink:

Hey,
I’m new to this and have an identical issue.
How did you apply your mitigation script?

What @hsepm is showing is two new sensors, that corrects the readout from the router integration.

Or you could use the range filter, which does the same and no need for templates.

Help out the guy, instead of just posting half claims please, what you suggest is also new sensors, but give him some examples.

ok, so the native sensors of the fritzbox are called something like:

 sensor.fritzbox_kib_s_received
 sensor.fritzbox_kib_s_sent

To filter out negative values, you have to create a template-Sensor based on this native sensor:

  - platform: filter
    name: sys_netin
    entity_id: sensor.fritzbox_kib_s_received
    filters:
      - filter: range
        upper_bound: 60000.0
        lower_bound: 0.0

  - platform: filter
    name: sys_netout
    entity_id: sensor.fritzbox_kib_s_sent
    filters:
      - filter: range
        upper_bound: 10000.0
        lower_bound: 0.0

As mentioned in the documentation https://www.home-assistant.io/integrations/filter/

fhe range-filter will replace any value out of the defined range with the value of the corresponding boundary.

1 Like