Trying to convert kb/s sent to Mb/s sent

thank you all for your input and replies.

ive tried the following with the same errors… Entity is non-numeric sensor.bytes_sent

- platform: template
  sensors:
    bytes_received:
      friendly_name: "MB Received"
      unit_of_measurement: 'MB/s'
      value_template: "{{ states.sensor.arris_tg2492lg_85_router_kbyte_sec_received | filesizeformat() }}/s"
    bytes_sent:
      friendly_name: "MB Sent"
      unit_of_measurement: 'MB/s'
      value_template: "{{ (states('sensor.arris_tg2492lg_85_router_kbyte_sec_sent') | int / 1024) | round(1) }}"

also tried to alter the filesizeformat(,bytes=true) (dunno if thats right or not but it didnt work… )

That’s … unusual.

You can tack on a float filter at the end of the template to be doubly certain it produces a numeric value.

  value_template: "{{ (states('sensor.arris_tg2492lg_85_router_kbyte_sec_sent') | int / 1024) | round(1) | float }}"

If that still causes it to report: ‘Entity is non-numeric sensor.bytes_sent’ then there’s something else wrong, beyond what is visible to me given the information you’ve provided.

Out of curiosity, paste this into the Template Editor and tell me what it reports (or show me a screenshot of the result):

{{ (states('sensor.arris_tg2492lg_85_router_kbyte_sec_sent') | int / 1024) | round(1) }}

just got back to sorting this out and your ‘code’ worked perfectly. the problem was me, I made a typo somehow and on top of that when i was testing it i somehow managed to select the wrong sensor… I changed the round(1) to round(3) and everything is working perfectly now… thank you!!

again the problem was human error on my part… Sorry

1 Like

Hi all, apologises for reviving an old post but I too am having issues here. I have tired all different types of codes.

I have my Entity ID which is pulling through in Bytes.

image

I have added this code but the figures are not converted. Has I missed a step?

  • platform: template
    sensors:
    bytes_sent:
    friendly_name: “MB Sent”
    unit_of_measurement: ‘MB/s’
    value_template: “{ (states(‘sensor.rt_ax58u_29d0_b_sent’) | int / 1000) | round(1) }}”

I’m no expert (still a novice in fact.) But your sensors don’t match here… in your top entity_id you have sensor.rt_ax58u_29d0_b_recieved but in the template you have sensor.rt_ax58u_29d0_b_sent as far as I can see your top one should be sensor.bytes_sent as that’s your new converted sensor

I suspect he has a similar template for both rx and tx.

@wideboys182, please format your pasted configuration correctly. See point 11 here, How to help us help you - or How to ask a good question

@Rdoull apologises I have mixed up my code with the wrong sensor as @tom_l states I have one for bytes sent and bytes received.

@tom_l thank you for the advice, I see copy and paste in to the forum loses its formatting and still very new to all this. The code I have is:

   - platform: template
     sensors:
      bytes_sent:
       friendly_name: "MB Sent"
       unit_of_measurement: 'MB/s'
       value_template: "{ (states('sensor.rt_ax58u_29d0_b_sent') | int / 1000) | round(1) }}"

an image from the configuration.yaml if this is more suitable:

Should be:

value_template: "{{ (

Images of text are not usually much use as it is not possible to copy and paste corrections. Exceptions being: where demonstrating something in the UI, template editor results, or where line numbers are needed.

Thanks. I have added that amendment to my code and rebooted but data is still showing in B:

image

You need to change the Lovelace card to graph your new template sensor, sensor.bytes_sent.

I do not have this sensor available?

Is my understanding correct that with this template it should create a new sensor called sensor.bytes_sent which will use the data from sensor.rt_ax58u_29d_b_sent but in a different format as defined by the template?

What am I missing?

Did you restart after creating the template sensor?

Yep no new sensor has been created. Even rebooted 2 more times for good will and still nothing

Did you do a config check before restarting?

Were there any errors?

Also, never reboot. Restarting the HA application is sufficient. In fact there is a Reload template Entities service you can use instead of restarting, but make sure it passes the config check first.

I didn’t check the config before restarting but normally if there are any errors these appear in the Log which shows no issues. Doing a config check now and it says “Configuration valid!”. So not sure why this wouldn’t be working.

What’s the Reload template for entities as this would be useful.

Wait. That template sensor definition should be under sensors: not default_config:

Or if you have a line like this in your configuration.yaml file:

sensor: !include sensors.yaml

Then it should be in your sensors.yaml file.

@tom_l thank you do much for your help its much appreciated. This has now worked. I am now seeing MB rather than B. On to the next issue. Looking at this more it appears to be a running total rather than a daily total. Need to look how I can get daily totals

That would be a task for the utility meter integration:

utility_meter:
  kb_sent_per_day:
    source: sensor.bytes_sent
    cycle: daily
1 Like

Wow that looks a whole lot simpler than the code I have found here:

Update

I have tested Utility Meter and asked it to reset hourly ( to see if it works) but as you can see nothing has reset to 0 so doesn’t look to work. But then I am not 100% sure how correct these figures are given my total download has not moved for a long time though states it was updated 4 minutes ago.

Thank you so much for tagging me in this! I was just logging into the forum to try to grab my old solution after a data loss of my past HA instance, and this may make things way easier if it works.