IKEA FÖRNUFTIG in Home-Assistant

They just released a new version and the changelog states about the long term stats. So hopefully this works - when I get my chips in the mail :slight_smile:

I was wondering if we could add more “steps” to the fan. I mean it’s just controlled by the clock signal, right? So we could pickup the clock signal on one port from the board and offer a clock signal from the ESP32 to the fan instead, right? :thinking:

The issue I like to solve is, that setting one is moving like no air while setting two is quite loud. So having a way to set it to something like 1.5 would be nice.

I know this may screw up the filter counter.

Edit: Oh wait, I overlooked the return signal via FG. So I guess we could emulate the return signal to the board instead? :thinking:

How about just sending last_reset as the current time minus the interval - like one minute?

This way we just have to send a Wh for the last minute and the current time with a minimal calculation and HA does the rest for us :slight_smile:

I love the idea :smiley: .

Sadly ESPhome does not allow for setting last_reset at all as far as I know: Sensor Component — ESPHome.

I don’t see a way to do it without customize.yaml which IMHO is not worth it fur such a small consumer.

Regarding your idea to add more steps:
I haven’t looked into this at all but I don’t see why it should not be possible. Scaling the return signal from the fan is one way to do it. Check out the pulse counter for reading the pulse from the PCB and PWM Output for generating a new signal. Not sure if the PWM output is able to go to a frequency that low.

Another idea would be to replace the PCB completely and drive the motor directly.
It may even be possible to keep it all the same and switch between setting 1 and 2 a few times every second. As this accelerates/decelerates the motor all the time it may wear out quite fast. So… not recommended.

I’m happy with the settings the original PCB offers. I use home-assistant to only let it run when there is no-one in the room so the noise is not an issue. Please give us an update if you dig deeper and find a way to add additional steps.

I’m actually still stuck on getting the board working as you have, I flashed my Esp8266 but as soon as I started it with the wires attached I only get a solid light and no response on the serial port.

I tried two chips, so I can rule out a chip failure - so I guess I connected something wrong :thinking:

I only used the connections to the board and cut the knob’s connections from the board. I haven’t soldered them to the Esp8266 since I won’t use the knob anyway.

Regarding my idea: I actually would like to have HA run a PID controller, so I can set it to something like 0 as a target and it will adjust the fan speed as necessary.

This would of course require more than just 3 steps, as setting 2 feels already too noisy and 1 is too little to keep my office “clean”, after venting some outside air through the windows.

Can you do me a favour and record the duty cycles and the frequency of the PWM to the motor on each step? :slight_smile:

And if I go ahead with the replacement I might just add a differential pressure sensor to see how much resistance the filter creates.

Not sure if this is maybe how the motor signal is used originally, as the duty cycle will request a known good RPM. And if the fan cannot reach it, it will set the filter lamp to on.

Can someone test this theory by taping the outlet up to like 90% and run the fan on high?

If the filter lamp turns on after a while we could test which frequency the chip expect the fan to do at least.

@Habbie hey, can you assist a bit here? I would like to have the energy consumption send to HA with the timestamp of the last measurement in the last_reset field, to avoid having to store the value persistent… or count in memory and have the first valid synced time after boot send out to HA as last_reset and then start doing the accounting in memory…

Is there a chance to do this in ESPHome?

I found the issue in my setup - I accidentally pushed two wires together on installation.

I’m not sure if this damaged the d1 mini or what, but if I enable my D4 pin it will only turn on the LED.

I switched the ports and it’s fine now :slight_smile:

I know way too little about ESPHome to be useful in this case, sorry! I suggest trying the ESPHome Discord.

Good to hear you were able to solve the issue.

I removed the LED as I needed all the ports available on an ESP8266 and the LED was connected to one of them. So at one setting (I don’t remember which one) the LED was always on.

Sorry, I can’t help with further investigations as my FÖRNUFTIG is kinda “productive” and I don’t have another one to toy around with.

@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:

  - 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
          lambda: 'return state < 0.1;'
          - output.turn_off: gpio_d5
          - output.turn_off: gpio_d7
          - output.turn_off: gpio_d6
          - sensor.template.publish:
              id: power_consumption
              state: 0.1

          - if:
                lambda: 'return state < 0.4;'
                - output.turn_on:  gpio_d5
                - output.turn_off: gpio_d7
                - output.turn_off: gpio_d6
                - sensor.template.publish:
                    id: power_consumption
                    state: 1.5
                - if:
                      lambda: 'return state < 0.7;'
                      - output.turn_off: gpio_d5
                      - output.turn_on:  gpio_d7
                      - output.turn_off: gpio_d6
                      - sensor.template.publish:
                          id: power_consumption
                          state: 6.5
                      - 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:

On the idea of driving the fan directly I have just found an article:

If anyone is experienced with the PWM modul of ESPhome, could help me piece out a config for that. It should allow us gradually control the fan curve.

Have a look here

Graphs comparing PM1006 (in the unmodified IKEA setup including the automatic fan management) to an SDS011 (set to 1 minute intervals with the ESPHome driver) - in every picture, the PM1006 is purple (usually the bottom line). These results are not as terrible as I’ve seen other people report!

1 Like

So far I have managed to send any preset frequency to the fan, and its spins on various speed based on that, but I cannot figure out how to modify this on the the fly, lets say with a slide in HA

  name: $devicename
  platform: ESP8266
  board: d1_mini

  devicename: esp82-fornuftig1
  friendly_name: FORNÜFTIG

# Insert your SSID and Your PWD after inital setup
    - ssid: "myssid"
      password: "mypass"
  # Enable fallback hotspot (captive portal) in case wifi connection fails
    ssid: "Airfilteresp Fallback Hotspot"
    password: "pass"

# Enable logging
      # Make adc input less verbose
      adc: INFO

# Enable Home Assistant API
  password: xxxxxxxxxxx

# Enable OTA upgrade
  safe_mode: True
  password: "e5a460b498b3a7a1471b4cc7a443e45d"

  - platform: esp8266_pwm
    pin: D1
    frequency: 50 Hz
    id: pwm_output

 - platform: speed
   output: pwm_output
   id: fan_internal
   name: "$friendly_name Fan"

I’m pretty sure its something with

- output.esp8266_pwm.set_frequency:

here ESP8266 Software PWM Output — ESPHome but I’m too novice for this.

Has the fan entity in HA not got a speed slider ?

I think your PWM frequency needs to be higher, maybe 1000Hz, this is a constant.

The Speed Fan does the speed adjustment

Hey everyone.

Are you not supposed to cut the unused leg of the encoder?
I cut all 5 legs on that side and connected the required 4 to the ESP8266.
However, I’m having issues with the manual control. WIFI control works great!

Encoder Position 1 results in speed 1, D1: L, D5: H, D6: L, D7: L. It should be off.
Encoder Position 2 results in speed 2, D1: L, D5: L, D6: H, D7: L. It should be speed 1.
Encoder Position 3 results in speed 2, D1: L, D5: L, D6: H, D7: L. Correct
Encoder Position 4 results in speed 3, D1: L, D5: L, D6: L, D7: H. Correct

Positions 1 and 2 aren’t behaving as intended.

Thanks for your help,

Great project!
I just wanted to add this for posterity since it stumped me for a while: I used a MP2315 step down converter (using it to step down to 3.3V) and a Wemos D1 Mini, and I couldn’t flash the D1 Mini after soldering all the wires. I just got this error:
A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header
I was able to flash the firmware when i plugged in the 24V power supply of the fan. Don’t know why this happens but it does! So try plugging in the power supply if you are experiencing problems with the initial flashing.

Did anyone of you use a 5V <-> 3.3V level shifter, as Wemos use 3.3V GPIO and Förnuftig is at 5V.
I don’t want to fry my Wemo and was wondering about that.

1 Like

Somewhat of a stupid question but how did you wire up the fan following the guide in Making the stupid dumb. Vindriktning and Förnuftig - Qball's Weblog? Having never wired up a PWM fan before I really don’t want to let out the magic smoke and it’s really hard to see from the pictures in that guide.

Hi, how do you set up automation to set the speed of the fan? Thanks