Giter Club home page Giter Club logo

Comments (5)

CoMPaTech avatar CoMPaTech commented on August 10, 2024 1

I'll have a look at how to rewrite it to a better and more reproducable thing

from esphome_c1101.

CoMPaTech avatar CoMPaTech commented on August 10, 2024 1

Hi @hubertgruber - I recently moved everything and didn't realise not using the templating broke that way. I tried rewriting it already but there is a snag. It seems esphome / fan is not able to 'take' speed settings from something external.

I'll leave my rewrite of the esp yaml below - if you are only using the fan-component (i.e. skip setting high for 10/20/30 minutes etc.) and not have the intent to 'read' whatever the physical switches are sending you can get away with it.

The below code is based off having the custom switches as already included in the original version.

fan:
  - platform: speed
    speed_count: 3
    output: mech_vent
    name: "Mechanische ventilatie"
    restore_mode: NO_RESTORE
    on_turn_on:
    - logger.log: "Fan Turned On, setting to 10min!"
    - switch.turn_on: fansendt1
        
    on_turn_off:
    - logger.log: "Fan Turned Off, setting to low speed!"
    - switch.turn_on: fansendlow
        

output:
  - platform: template
    id: mech_vent
    type: float
    write_action:
      - if:
          condition:
            lambda: return ((state == 0));
          then:
            # action for off
            - logger.log: "Fan set to low speed"
            - switch.turn_on: fansendlow
      - if:
          condition:
            lambda: return ((state > 0) && (state < .34));
          then:
            # action for low
            - logger.log: "Fan set to low speed"
            - switch.turn_on: fansendlow
      - if:
          condition:
            lambda: return ((state > .34) && (state < .67));
          then:
            # action for medium
            - logger.log: "Fan set to medium speed"
            - switch.turn_on: fansendmedium
                
      - if:
          condition:
            lambda: return ((state == 1));
          then:
            # action for high
            - logger.log: "Fan set to high speed"
            - switch.turn_on: fansendhigh

If it doesn't (re)build for you on homeassistant itself (using the esphome addon) - it works for me using this on the top

esphome:
  name: {yournamehere}
  platform: ESP8266
  board: d1_mini_lite
  libraries:
    - SPI
    - https://github.com/CoMPaTech/esphome_itho.git
    - Ticker
  includes:
    - ITHO/fancontrol.h

from esphome_c1101.

hubertgruber avatar hubertgruber commented on August 10, 2024 1

Closing because fan now works from HA OS 2022.2 onward with new code.

from esphome_c1101.

CoMPaTech avatar CoMPaTech commented on August 10, 2024

Which - in less detail - is also what https://github.com/CoMPaTech/esphome_c1101_alt already does - so you might want to give that a spin as well

from esphome_c1101.

hubertgruber avatar hubertgruber commented on August 10, 2024

Thank you very much! I got it working on my system too! I had to remove the restore_mode and add id's for the previously made custom switches, but it works like a charm again now! Here's my code for completeness:

esphome:
  name: esp_atmega_itho_1
  platform: ESP8266
  board: nodemcuv2
  includes: 
    - c1101.h
    - ITHO/fancontrol.h
  libraries: 
    - SPI
    - https://github.com/CoMPaTech/esphome_itho.git
    - Ticker
    
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  domain: xxsecretxx

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp Atmega Itho 1"
    password: !secret backup_password

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret backup_password_2

ota:
  password: !secret backup_password_2
  
switch:
- platform: custom
  lambda: |-
    auto fansendlow = new FanSendLow();
    App.register_component(fansendlow);
    return {fansendlow};
  switches:
    name: "FanSendLow"
    id: fansendlow

- platform: custom
  lambda: |-
    auto fansendmedium = new FanSendMedium();
    App.register_component(fansendmedium);
    return {fansendmedium};
  switches:
    name: "FanSendMedium"
    id: fansendmedium

- platform: custom
  lambda: |-
    auto fansendhigh = new FanSendHigh();
    App.register_component(fansendhigh);
    return {fansendhigh};
  switches:
    name: "FanSendHigh"
    id: fansendhigh

- platform: custom
  lambda: |-
    auto fansendt1 = new FanSendIthoTimer1();
    App.register_component(fansendt1);
    return {fansendt1};
  switches:
    name: "FanSendTimer1"
    id: fansendt1

- platform: custom
  lambda: |-
    auto fansendt2 = new FanSendIthoTimer2();
    App.register_component(fansendt2);
    return {fansendt2};
  switches:
    name: "FanSendTimer2"
    id: fansendt2

- platform: custom
  lambda: |-
    auto fansendt3 = new FanSendIthoTimer3();
    App.register_component(fansendt3);
    return {fansendt3};
  switches:
    name: "FanSendTimer3"
    id: fansendt3

- platform: custom
  lambda: |-
    auto fansendjoin = new FanSendIthoJoin();
    App.register_component(fansendjoin);
    return {fansendjoin};
  switches:
    name: "FanSendJoin"
    id: fansendjoin

# Rinse/repeat for the timers
# see outstanding question in c1101.h
# on multiple switches handling

text_sensor:
- platform: custom
  lambda: |-
    auto fanrecv = new FanRecv();
    App.register_component(fanrecv);
    return {fanrecv->fanspeed,fanrecv->fantimer};
  text_sensors:
    - name: "FanSpeed"
    - name: "FanTimer"

#### Fix for HA OS 2022.2
fan:
  - platform: speed
    speed_count: 3
    output: mech_vent
    name: "Bathroom fan"
    # restore_mode: NO_RESTORE
    on_turn_on:
    - logger.log: "Fan Turned On, setting to 10min!"
    - switch.turn_on: fansendt1
        
    on_turn_off:
    - logger.log: "Fan Turned Off, setting to low speed!"
    - switch.turn_on: fansendlow
        

output:
  - platform: template
    id: mech_vent
    type: float
    write_action:
      - if:
          condition:
            lambda: return ((state == 0));
          then:
            # action for off
            - logger.log: "Fan set to low speed"
            - switch.turn_on: fansendlow
      - if:
          condition:
            lambda: return ((state > 0) && (state < .34));
          then:
            # action for low
            - logger.log: "Fan set to low speed"
            - switch.turn_on: fansendlow
      - if:
          condition:
            lambda: return ((state > .34) && (state < .67));
          then:
            # action for medium
            - logger.log: "Fan set to medium speed"
            - switch.turn_on: fansendmedium
                
      - if:
          condition:
            lambda: return ((state == 1));
          then:
            # action for high
            - logger.log: "Fan set to high speed"
            - switch.turn_on: fansendhigh
#### End fix for HA OS 2022.2

from esphome_c1101.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.