So, there are multiple ways of doing this (this is the beauty of Home Assistant) and I will try to share some here. Hopefully other people will come with more ideas and then you can get inspired and find what works better for you.
Card-mod is probably one of the most flexible and powerful ways, but it can be an issue if you are not confortable with CSS.
For cases like this where you will have to use templates, the Mushroom Template Card is also great, and you will be able to setup one and then duplicate that 40 times, just change one line (your sensor id). It might be a good option for 40 sensors:
Try this:
type: custom:mushroom-template-card
entity: sensor.204_energy_usage
primary: '{{ state_attr(entity, ''friendly_name'') }}'
secondary: |-
{%- set power = states(entity) | float(0) %} {%- if power < 100 %}
Stopped
{%- elif power < 250 %}
Idle
{%- elif power < 1000 %}
Engaged
{%- else %}
Running
{%- endif %}
{{ power | round(1) }}W
icon: mdi:engine
icon_color: |-
{% set power = states(entity) | float(0) %} {% if power < 100 %}
blue
{% elif power < 250 %}
green
{% elif power < 1000 %}
orange
{% else %}
red
{% endif %}
fill_container: true
multiline_secondary: true
tap_action:
action: more-info
hold_action:
action: more-info
layout: vertical
If you go this way, either with Mushroom or other single-entity card, you will need one card per CNC so you may want organize those inside a grid card, so you can define the number or cards per row based on your screen size:
type: grid
cards:
- type: custom:mushroom-template-card
entity: sensor.201_energy_usage
primary: '{{ state_attr(entity, ''friendly_name'') }}'
secondary: |-
{%- set power = states(entity) | float(0) %} {%- if power < 100 %}
Stopped
{%- elif power < 250 %}
Idle
{%- elif power < 1000 %}
Engaged
{%- else %}
Running
{%- endif %}
{{ power | round(1) }}W
icon: mdi:engine
icon_color: |-
{% set power = states(entity) | float(0) %} {% if power < 100 %}
blue
{% elif power < 250 %}
green
{% elif power < 1000 %}
orange
{% else %}
red
{% endif %}
fill_container: true
multiline_secondary: true
tap_action:
action: more-info
hold_action:
action: more-info
layout: vertical
- type: custom:mushroom-template-card
entity: sensor.202_energy_usage
primary: '{{ state_attr(entity, ''friendly_name'') }}'
secondary: |-
{%- set power = states(entity) | float(0) %} {%- if power < 100 %}
Stopped
{%- elif power < 250 %}
Idle
{%- elif power < 1000 %}
Engaged
{%- else %}
Running
{%- endif %}
{{ power | round(1) }}W
icon: mdi:engine
icon_color: |-
{% set power = states(entity) | float(0) %} {% if power < 100 %}
blue
{% elif power < 250 %}
green
{% elif power < 1000 %}
orange
{% else %}
red
{% endif %}
fill_container: true
multiline_secondary: true
tap_action:
action: more-info
hold_action:
action: more-info
layout: vertical
- type: custom:mushroom-template-card
entity: sensor.203_energy_usage
primary: '{{ state_attr(entity, ''friendly_name'') }}'
secondary: |-
{%- set power = states(entity) | float(0) %} {%- if power < 100 %}
Stopped
{%- elif power < 250 %}
Idle
{%- elif power < 1000 %}
Engaged
{%- else %}
Running
{%- endif %}
{{ power | round(1) }}W
icon: mdi:engine
icon_color: |-
{% set power = states(entity) | float(0) %} {% if power < 100 %}
blue
{% elif power < 250 %}
green
{% elif power < 1000 %}
orange
{% else %}
red
{% endif %}
fill_container: true
multiline_secondary: true
tap_action:
action: more-info
hold_action:
action: more-info
layout: vertical
- type: custom:mushroom-template-card
entity: sensor.204_energy_usage
primary: '{{ state_attr(entity, ''friendly_name'') }}'
secondary: |-
{%- set power = states(entity) | float(0) %} {%- if power < 100 %}
Stopped
{%- elif power < 250 %}
Idle
{%- elif power < 1000 %}
Engaged
{%- else %}
Running
{%- endif %}
{{ power | round(1) }}W
icon: mdi:engine
icon_color: |-
{% set power = states(entity) | float(0) %} {% if power < 100 %}
blue
{% elif power < 250 %}
green
{% elif power < 1000 %}
orange
{% else %}
red
{% endif %}
fill_container: true
multiline_secondary: true
tap_action:
action: more-info
hold_action:
action: more-info
layout: vertical
- type: custom:mushroom-template-card
entity: sensor.205_energy_usage
primary: '{{ state_attr(entity, ''friendly_name'') }}'
secondary: |-
{%- set power = states(entity) | float(0) %} {%- if power < 100 %}
Stopped
{%- elif power < 250 %}
Idle
{%- elif power < 1000 %}
Engaged
{%- else %}
Running
{%- endif %}
{{ power | round(1) }}W
icon: mdi:engine
icon_color: |-
{% set power = states(entity) | float(0) %} {% if power < 100 %}
blue
{% elif power < 250 %}
green
{% elif power < 1000 %}
orange
{% else %}
red
{% endif %}
fill_container: true
multiline_secondary: true
tap_action:
action: more-info
hold_action:
action: more-info
layout: vertical
- type: custom:mushroom-template-card
entity: sensor.206_energy_usage
primary: '{{ state_attr(entity, ''friendly_name'') }}'
secondary: |-
{%- set power = states(entity) | float(0) %} {%- if power < 100 %}
Stopped
{%- elif power < 250 %}
Idle
{%- elif power < 1000 %}
Engaged
{%- else %}
Running
{%- endif %}
{{ power | round(1) }}W
icon: mdi:engine
icon_color: |-
{% set power = states(entity) | float(0) %} {% if power < 100 %}
blue
{% elif power < 250 %}
green
{% elif power < 1000 %}
orange
{% else %}
red
{% endif %}
fill_container: true
multiline_secondary: true
tap_action:
action: more-info
hold_action:
action: more-info
layout: vertical
If you want to clean-up your screen a bit (as I understood you just wanna show the ones thar are engaged, right?) you can create a template sensor for each one of your CNCs and then use that in a conditional card, so you hide the ones that are not engaged.
The template sensor will look like:
template:
- sensor:
- name: 204_energy_usage_status
state: >-
{%- set power = states(entity) | float(0) %}
{%- if power < 100 %}
Stopped
{%- elif power < 250 %}
Idle
{%- elif power < 1000 %}
Engaged
{%- else %}
Running
{%- endif %}
Than you can have a conditional card which will only be visible if the CNC is engaged (or when you are in edit mode). It would be like this:
type: conditional
conditions:
- entity: sensor.204_energy_usage_status
state: Engaged
card:
type: custom:mushroom-template-card
entity: sensor.204_energy_usage
primary: '{{ state_attr(entity, ''friendly_name'') }}'
secondary: |-
{%- set power = states(entity) | float(0) %} {%- if power < 100 %}
Stopped
{%- elif power < 250 %}
Idle
{%- elif power < 1000 %}
Engaged
{%- else %}
Running
{%- endif %}
{{ power | round(1) }}W
icon: mdi:engine
icon_color: |-
{% set power = states(entity) | float(0) %} {% if power < 100 %}
blue
{% elif power < 250 %}
green
{% elif power < 1000 %}
orange
{% else %}
red
{% endif %}
fill_container: true
multiline_secondary: true
tap_action:
action: more-info
hold_action:
action: more-info
layout: vertical