[SOLVED] How to template sensor value in entities card?

Hello,

I am using IOT Link on several computers and it is reporting network upload/download as bit per seconds. It’s ok for me but, in Lovelace, I would like to display it as Megabit per seconds.

As there are multiple computers and NIC’s, I would like to avoid creating template sensors for every sensor and only template the display in Lovelace.

Do you know if there is a way to achieve this ? If I put the lines below in the template editor, it’s displaying what I would like so I guess the code is already present in Lovelace somewhere.

I also tried to use the custom card lovelace templater but it seems it does not work anymore in 0.116.

Ryzen : {{ (states('sensor.ryzen7800_network_0_bps_received') | float * 0.00001) | round(2) }}
Nuc Hades : {{ (states('sensor.nuchades_network_1_bps_received') | float * 0.00001) | round(2) }}
Gaming Tower : {{ (states('sensor.gamingtower_network_0_bps_received') | float * 0.00001) | round(2) }}
1 Like

SOLVED !

Somebody on Reddit pointed me to this custom entity :

3 Likes

It’d be helpful if you’d post the solution here for people searching for answers to similar problems. I can’t make heads or tails of how to make lovelace-template-entity-row do what you’re describing.

Hello,
My bad, I thought it was enough to point the link to the solution but templating is always complex to write correctly … (at least for me :slight_smile: ) )

This is how I did it and how it looks like in Lovelace :

image

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: sensor.ryzen7800_network_0_ipv4
        name: IP Address
      - entity: sensor.ryzen7800_system_uptime
        name: Uptime
      - type: 'custom:template-entity-row'
        icon: 'mdi:download'
        name: Mbits/Sec Received
        state: >-
          {{ (states('sensor.ryzen7800_network_0_bps_received') | float *
          0.00001) |round(2) }} Mbps
      - type: 'custom:template-entity-row'
        icon: 'mdi:upload'
        name: Mbits/Sec Sent
        state: >-
          {{ (states('sensor.ryzen7800_network_0_bps_sent') | float * 0.00001)
          |round(2) }} Mbps
    title: Ryzen 7800
    show_header_toggle: false
  - type: button
    entity: switch.ryzen_7800
    tap_action:
      action: toggle
    hold_action:
      action: call-service
      service: mqtt.publish
      service_data:
        topic: iotlink/workgroup/ryzen7800/commands/shutdown
        payload: ''
    icon: 'mdi:power'
    name: Power
    icon_height: 100px

10 Likes