danielcuthbert / home-assistant

Just a dump of all the home assistant things I've been tinkering with
63 stars 0 forks source link

Better FÖRNUFTIG control #2

Open wjtje opened 2 years ago

wjtje commented 2 years ago

It is possible to get full control over the fan inside the FÖRNUFTIG if you send a custom signal to the fan CLK instead.

ESP FÖRNUFTIG Description
D2 CLK The speed-control of the fan.
D1 FG The tachometer of the fan.
D0 R13 Fan power.

image

Example esphome code:

substitutions:
  device_name: "FÖRNUFTIG"

output:
  # Internal output (real)
  - platform: esp8266_pwm
    id: fan_output_internal
    pin: D2
    frequency: 100hz
  # Fan ouput that will be mapped to the internal output
  - platform: template
    id: fan_output
    type: float
    write_action:
      - if:
          condition:
            lambda: 'return state > 0.0 && state <= 1.0;'
          then:
            # Fan needs to turn on
            - switch.turn_on:
                id: fan_power_switch
            - output.set_level:
                id: fan_output_internal
                level: 50%
            - output.esp8266_pwm.set_frequency:
                id: fan_output_internal
                frequency: !lambda |-
                  return map((int)(state * 100), 1, 100, 100, 300);
          else:
            # Fan needs to turn off
            - output.turn_off:
                id: fan_output_internal
            - switch.turn_off:
                id: fan_power_switch
  # Output for the fan power
  - platform: gpio
    pin: D0
    id: fan_power

sensor:
    # The internal tachometer
  - platform: pulse_counter
    pin: D1
    name: ${device_name} Tachometer
    update_interval: 1s
    unit_of_measurement: "Hertz"
    accuracy_decimals: 0
    filters:
      - multiply: 0.0166666
    # Disable power to the Fan when it goes to fast
    on_value_range:
      above: 370
      then:
        - switch.turn_off: fan_power_switch

fan:
  - platform: speed
    output: fan_output
    id: device_fan
    name: ${device_name} Fan

switch:
  - platform: output
    name: ${device_name} Fan power
    id: fan_power_switch
    output: fan_power
wjtje commented 2 years ago

Personally, I removed the main chip from the logic board and implemented almost all the features inside esphome.