Fibaro double switch 2 energy reading

Hi! I’m new to the community and I wanted to contribute to other new HA users.

I wrote this template for the fibaro double switch 2 energy sensors. There are different ways to get the actual switch in home assistant so I leave that to you. I had trouble finding how to get the sensor values from the switch and how to get it in hass.io so I hope it will help someone like me who is new :slight_smile:

Copy this under sensor: in your configuration.yaml , replace “your_switch” with the name of your switch and restart home assistant.
I hope I’m copying it in the right way. If I’m not it’s 2 spaces from the edge at the first line.

- platform: template
    sensors:
      your_switch_kwh:
        friendly_name: 'Today kwh'
        value_template: '{{state_attr("switch.your_switch","today_energy_kwh")}}'
        unit_of_measurement: 'kWh'
      your_switch_watts:
        friendly_name: 'Current power W'
        value_template: '{{state_attr("switch.your_switch","current_power_w")}}'
        unit_of_measurement: 'W'
2 Likes

Hi @alexander.heikkila,

Appreciate this post is a little old, and Ive managed to get this working with a single entity. However, I’m trying to create a sensor for the total power usage from multiple Fibaro switches. (in my case lights).

The code I have below seems to show as unavailable in the state lookup and within a graph, it shows no values, any idea what I could be doing wrong?

  - platform: template
    sensors:
      total_power_usage:
        value_template: "{{state_attr('light.hall_hall_lights_151','current_power_w') +
        state_attr('light.kitchen_kitchen_lights_109','current_power_w') +
        state_attr('light.laundry_laundry_lights_161','current_power_w') +
        state_attr('light.dining_dining_lights_141','current_power_w') +
        state_attr('light.lounge_lounge_lights_146','current_power_w')+
        state_attr('light.master_bed_master_bed_main_ligh_129','current_power_w') +
        state_attr('light.master_bed_master_bed_entrance_200','current_power_w') +
        state_attr('light.master_bed_master_hall_240','current_power_w') +
        state_attr('light.master_bed_wardrobe_166','current_power_w') +
        state_attr('light.guest_bedroom_guest_bathroom_mirro_135','current_power_w') +
        state_attr('light.guest_bedroom_guest_bathroom_mirro_136','current_power_w') +
        state_attr('light.guest_bedroom_guest_lights_174','current_power_w') +
        state_attr('light.main_balcony_balcony_lights_81','current_power_w') +
        state_attr('light.balcony_small_balcony_lights_171','current_power_w') +
        state_attr('light.guest_wc_wc_156','current_power_w') | round(1) }}"
        friendly_name: 'Total power usage'
        unit_of_measurement: 'w'

graph

any suggestions what im doing wrong?

okay, realised im being stupid… well just new to json actually, so I had each entity on a new line, but seems that is not possible here, so ive condensed them all onto a single line and it works… however this isnt currently showing me the right value. (not the sum of all)

      value_template: '{{ (state_attr("light.hall_hall_lights_151","current_energy_kwh") | float) + (state_attr("light.kitchen_kitchen_lights_109","current_energy_kwh") | float) + (state_attr("light.laundry_laundry_lights_161","current_energy_kwh") | float) + (state_attr("light.dining_dining_lights_141","current_energy_kwh") | float) + (state_attr("light.lounge_lounge_lights_146","current_energy_kwh") | float)+ (state_attr("light.master_bed_master_bed_main_ligh_129","current_energy_kwh") | float) + (state_attr("light.master_bed_master_bed_entrance_200","current_energy_kwh") | float) + (state_attr("light.master_bed_master_hall_240","current_energy_kwh") | float) + (state_attr("light.master_bed_wardrobe_166","current_energy_kwh") | float) + (state_attr("light.guest_bedroom_guest_bathroom_mirro_135","current_energy_kwh") | float) + (state_attr("light.guest_bedroom_guest_bathroom_mirro_136","current_energy_kwh") | float) + (state_attr("light.guest_bedroom_guest_lights_174","current_energy_kwh") | float) + (state_attr("light.main_balcony_balcony_lights_81","current_energy_kwh") | float) + (state_attr("light.balcony_small_balcony_lights_171","current_energy_kwh") | float) + (state_attr("light.guest_wc_wc_156","current_energy_kwh") | float) + (state_attr("switch.kitchen_kitchen_water_heater_209","current_energy_kwh") | float) }}'

But with that, does anyone know how to do this on multiple lines? is it possible as it would be easier to read!

Hi! I actually would like only to display in a graph the actual power consumption in watts. Do I understand correctly that I need to create a “dummy” sensor with platform template? I am also using Fibaro.

Sorry for not replying to you. I’ve been off on my ha and just letting it do it’s thing while I’ve been moving so I can’t really help out unfortunately :joy: