IKEA FÖRNUFTIG in Home-Assistant

@tht well my works now, so everything is fine :slight_smile:
I would just recommend to not use D4 as it won’t work (if I haven’t just fried some connection - is a bit since I soldered the last time :D)

Hey Habbie, thanks anyway. I figured it out. Using last_reset is actually problematic as it is already deprecated anyway.

So here’s how you get the Energy Consumption from the Förnuftig into your Energy Dashboard:

Add these two additional sensors:

sensor:
  - platform: template
    name: '$friendly_name - Power consumption'
    id: power_consumption
    device_class: power
    state_class: measurement
    unit_of_measurement: 'W'
    accuracy_decimals: 1
    update_interval: 0s
  - platform: integration
    name: "$friendly_name - Consumed Energy"
    sensor: power_consumption
    time_unit: 'h'
    device_class: energy
    state_class: total_increasing
    unit_of_measurement: 'Wh'
    restore: false
    integration_method: left

And expand the fanout internal template with the consumption values, as @tht showed before (my pins are different than yours):

  - platform: template
    id: fan_out_internal
    type: float
    write_action:
      if:
        condition:
          lambda: 'return state < 0.1;'
        then:
          - output.turn_off: gpio_d5
          - output.turn_off: gpio_d7
          - output.turn_off: gpio_d6
          - sensor.template.publish:
              id: power_consumption
              state: 0.1

        else:
          - if:
              condition:
                lambda: 'return state < 0.4;'
              then:
                - output.turn_on:  gpio_d5
                - output.turn_off: gpio_d7
                - output.turn_off: gpio_d6
                - sensor.template.publish:
                    id: power_consumption
                    state: 1.5
              else:
                - if:
                    condition:
                      lambda: 'return state < 0.7;'
                    then:
                      - output.turn_off: gpio_d5
                      - output.turn_on:  gpio_d7
                      - output.turn_off: gpio_d6
                      - sensor.template.publish:
                          id: power_consumption
                          state: 6.5
                    else:
                      - output.turn_off: gpio_d5
                      - output.turn_off: gpio_d7
                      - output.turn_on:  gpio_d6
                      - sensor.template.publish:
                          id: power_consumption
                          state: 15

Only limitation is, that the statistics will only be calculated and pushed to HA if you set a fan speed. So if you want to push it like once a minute you need an interval timer, like I used in the config for the Vindriktning. It’s just a bit complex for my liking, so I stick with an automation which just sends a fan speed setting depending on the Vindriktning sensor reading. :slight_smile: