14yannick / esphome-hcpbridge

esphome component to connect to Hörmann Garage Door
MIT License
5 stars 2 forks source link

Component template.binary_sensor took a long time for an operation (128 ms) #3

Closed webflash-aj closed 2 months ago

webflash-aj commented 2 months ago

Hi @14yannick

Don't know.. if it's an issue.. or an expected behavior. I got a lot of Messages "took a long time".

Is this "normal"? Can I ignore, or does my yaml need some more finetuning?

Thanks for your great work

Andy

image

14yannick commented 2 months ago

Strange behavior I never had a warning on this components. It looks like you have a warning on all components. I would try to power off your motor and power it on again if you still get the message share your yaml an exact hardware used.

webflash-aj commented 2 months ago

sorry, i've been very busy the last few days and haven't gotten around to replying.

Basically, the ESP has been running without any problems for 2-3 days now. Maybe you can just ignore the warnings.

It is a “simple” ESP32 with USB-C and an RS485 board which is powered directly via the BUS from the Hörmann door.

Components: ESP32 https://de.aliexpress.com/item/1005006336964908.html RS485 https://de.aliexpress.com/item/1005006485141586.html Step-Down-Modules https://de.aliexpress.com/item/32653212622.html

IMG_0977

esphome:
  name: hcpbridge
  libraries:
    - emelianov/modbus-esp8266
  platformio_options:
    board_build.f_cpu: 240000000L
    board_build.flash_mode: qio
    monitor_speed: 9600
    monitor_filters: esp32_exception_decoder
    lib_ldf_mode: deep+
    # board_build.f_flash: 40000000L

external_components:
    #source: github://mapero/esphome-hcpbridge
    source: github://14yannick/esphome-hcpbridge
    refresh: 0s

esp32:
  board: esp32dev
  framework:
    type: arduino

hcpbridge:
  is_connected:
    name: "HCPBridge Connected"
    id: hcpbridge_id
  rx_pin: 16 # optional, default=18
  tx_pin: 17 # optional, default=17
  #rts_pin : 1 # optional RTS pin to use if hardware automatic control flow is not available.

cover:
  - platform: hcpbridge
    name: Garage Door
    device_class: garage
    id: garagedoor_cover

binary_sensor:
  - platform: template
    name: "Garage Door Light sensor"
    internal: true 
    device_class: light
    id: sensor_light
    lambda: !lambda |-
      return (id(garagedoor_cover).get_light_state());
    on_state:
    #needed to correct the state fo the light  
      if:
        condition:
          or:
            - and:
              - binary_sensor.is_on: sensor_light
              - light.is_off: light_1
            - and:
              - binary_sensor.is_off: sensor_light
              - light.is_on: light_1
        then:
          - light.toggle: light_1
  - platform: template
    name: "relay state"
    id: sensor_relay
    lambda: !lambda |-
      return (id(garagedoor_cover).get_relay_state());
    #on_state:
    #create your automation based on relay state  

output:
  - platform: template
    type: binary
    id: output_light
    write_action:
      lambda: !lambda |-
        id(garagedoor_cover).set_light_state(state);

light:
  - platform: binary
    output: output_light
    id: light_1
    name: Garage Door Light

button:
  platform: template
  id: button_vent
  name: "Garage Door Vent"
  on_press:
    - lambda: |-
        id(garagedoor_cover).on_go_to_vent();

text_sensor:
  - platform: template
    id: sensor_templ_state
    name: "Garage Door State"
    update_interval: 5s
    filters:
      - lambda: |-
          static std::string last;
          if (x == last)
            return {};
          last = x;
          return x;
    lambda: |-
      std::string stateText;
      switch (id(garagedoor_cover).get_cover_state()) {
          case HoermannState::OPENING:
            stateText = "opening";
            break;
          case HoermannState::MOVE_VENTING:
            stateText = "move venting";
            break;
          case HoermannState::MOVE_HALF:
            stateText = "move half";
            break;
          case HoermannState::CLOSING:
            stateText = "closing";
            break;
          case HoermannState::OPEN:
            stateText = "open";
            break;
          case HoermannState::CLOSED:
            stateText = "closed";
            break;
          case HoermannState::STOPPED:
            stateText = "stopped";
            break;
          case HoermannState::HALFOPEN:
            stateText = "half open";
            break;
          case HoermannState::VENT:
            stateText = "venting";
            break;
          default:
            stateText = "unknown";
            break;
        }
      return {stateText};

switch:
  - platform: template
    id: switch_vent
    name: "Venting"
    lambda: |-
      return (id(garagedoor_cover).get_cover_state() == HoermannState::VENT);
    optimistic: True
    turn_on_action:
      - lambda: |-
          if (id(garagedoor_cover).get_cover_state() != HoermannState::VENT) {
            id(garagedoor_cover).on_go_to_vent();
          }
    turn_off_action:
      #without wait device not booting
      - wait_until:
          condition:
            binary_sensor.is_on: hcpbridge_id
      - if:
          condition:
            lambda :  |-
              return (id(garagedoor_cover).position != COVER_CLOSED);
          then:
            - cover.close: garagedoor_cover

api:
  encryption:
    key: "xxxxxxxx="
  services:
    - service: go_to_open
      then:
        - lambda: |-
            id(garagedoor_cover).on_go_to_open();
    - service: go_to_close
      then:
        - lambda: |-
            id(garagedoor_cover).on_go_to_close();
    - service: go_to_half
      then:
        - lambda: |-
            id(garagedoor_cover).on_go_to_half();
    - service: go_to_vent
      then:
        - lambda: |-
            id(garagedoor_cover).on_go_to_vent();

web_server:
  port: 80
  auth:
    username: !secret web_username
    password: !secret web_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# Enable logging
logger:
  level: DEBUG
  baud_rate: 9600

# Example configuration entry
ota:
  - platform: esphome
    password: "xxxxxxxx"
14yannick commented 2 months ago

Hi, But you still get the warning in you logs or does they disappeared? you can deactivated them by changing the log level. as described in this topic

logger:
  logs:
    component: ERROR

your board looks similar with the one I started with. next I then poorly designed a pcb discovering than some other dude create a much better one. image Now I'm using an M5 Stack Atom with a rs485 tail with an extension base (Number 1 on the picture) who is barely bigger than an esp32 devboard and the only thing I have to modify is to add a 120 Ohm R0805 resistor.

14yannick commented 2 months ago

I think we can close the Issue as it probably not originated by the component of this repository