Changing the gui - add temperature from switch?

Hi Guys

I’ve by misadventure started configuring my GUI, I had held of doing that, and just let HA place everything in a bundle on the Home, but curiosity got the better of me, and I’ve started looking into the HA GUI.

I have some switches imported from fritz!box, and they are shown nicely as they should.
Some of the features of the fritz switches, is that they measure wattage, and temperature.
I would very much like to display that in HA as well, but how do I ‘address’ these values?
In appdaemon I’ve added the temperature by just displaying the number from switch.server.temperature, but do I do that in HA?
It would be great if I could get the wattage shown as a graph, but as far as I can see I can only get the ‘current’ and ‘total’ from the sensor.

You can create template sensors. e.g.

sensor:
  - platform: template
    sensors:
      server_power:
        entity_id: switch.server
        value_template: "{{ state_attr('switch.server', 'current_power_w') | float }}"
        unit_of_measurement: W
        friendly_name: " Server Power"
      server_temperature:
        entity_id: switch.server
        value_template: "{{ state_attr('switch.server', 'temperature') | float }}"
        unit_of_measurement: '°C'
        friendly_name: " Server Temperature"

etc…

Similarly for the binary sensors:

binary_sensor:
  - platform: template
    sensors:
      server_locked:
        entity_id: switch.server
        value_template: "{{ is_state_attr('switch.server', 'locked', 'True' }}"
        device_class: lock
        friendly_name: " Server Lock"

More on these components:

Binary sensor classes:

More on templating:

2 Likes

Wow, excellent help, I had actually JUST figure out about the template sensor, and even got a result from it. Now on to the graph bit :slight_smile:

1 Like

Make sure you have the unit_of_measurement: defined in your sensor. That way you get a history graph of values. Otherwise it’s the bar/strip type of history.

Yup, I’ve set the unit_of_measurement for them, and they are shown nicely.
What does the ‘float’ do in your config example?

It make sure it’s a floating point number (number with decimal fraction). Wasn’t sure if it was required, so I added it.

Also good catch on the unit_of_measurement. I’ll edit my post for future reference.