i have connected my router to HA and i’m able to get a reading of the data sent and received in kbyte per second, I’d like to convert that to MB/s if possible.
i done a search on here and found the following post:
Invalid config for [sensor.template]: expected a dictionary for dictionary value @ data['sensors']['bytes_received']. Got None
expected a dictionary for dictionary value @ data['sensors']['friendly_name']. Got 'MB Received'
expected a dictionary for dictionary value @ data['sensors']['unit_of_measurement']. Got 'MB/s'
expected a dictionary for dictionary value @ data['sensors']['value_template']. Got '{{ states.sensor.arris_tg2492lg_85_router_kbyte_sec_received|filesizeformat()}}/s'
extra keys not allowed @ data['bytes_sent']. Got OrderedDict([('friendly_name', 'MB Sent'), ('unit_of_measurement', 'MB/s'), ('value_template', '{{ states.sensor.arris_tg2492lg_85_router_kbyte_sec_sent|filesizeformat()}}/s')]). (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
i have no idea what i am doing really so don’t understand how to fix it… can anyone help please?
edit:
brain fart … i had a look at the yaml again and noticed that my indentation was off…
Lovelace error message says: Entity is non-numeric sensor.bytes_sent
It would appear it wants a numeric value and sensor.bytes_sent isn’t providing one.
I assume the arris sensor is reporting a purely numeric value. However, then you subject its state to the filesizeformat filter which not only divides the value by 1000, it also appends kB to the result:
Then your template appends /s to that so the final result is a something like 12.5 kB/s which is clearly a string, not a number.
Try this:
value_template: "{{ (states('sensor.arris_tg2492lg_85_router_kbyte_sec_sent') | int / 1000) | round(1) }}"
It simply divides the arris sensor’s value by 1000 then rounds the result to one decimal place.
Ah, I see filesizeformat does not use binary by default.
filesizeformat ( value , binary=False )
Format the value like a ‘human-readable’ file size (i.e. 13 kB, 4.1 MB, 102 Bytes, etc). Per default decimal prefixes are used (Mega, Giga, etc.), if the second parameter is set to True the binary prefixes are used (Mebi, Gibi).
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
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
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.
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?