nekromant / esphome-lctech-4chanel-modules

ESPHome configs for LC-tech 4 channel modules.
12 stars 6 forks source link

errors compiling + not working #3

Closed Finkregh closed 4 years ago

Finkregh commented 4 years ago

thanks for your work!

i get these errors when i try to run it:

In file included from src/main.cpp:18:0:
src/lccomponent.h:3:25: fatal error: esphome/log.h: No such file or directory
 #include "esphome/log.h"
                         ^
compilation terminated.
*** [.pioenvs/klingelknopf/src/main.cpp.o] Error 1

then i change the include in lccomponent.h to #include "esphome/core/log.h". but that leads to these errors:

In file included from src/main.cpp:18:0:
src/lccomponent.h:15:3: error: 'binary_sensor' does not name a type
   binary_sensor::BinarySensor buttons[2];
   ^
src/lccomponent.h: In member function 'void LCButtons::update_button(uint8_t)':
src/lccomponent.h:33:5: error: 'buttons' was not declared in this scope
     buttons[button - 1].publish_state(!value);
     ^
src/lccomponent.h: At global scope:
src/lccomponent.h:43:67: error: 'output' has not been declared
 class LCFloatOutput : public Component, public UARTDevice, public output::FloatOutput {
                                                                   ^
src/lccomponent.h:43:75: error: expected '{' before 'FloatOutput'
 class LCFloatOutput : public Component, public UARTDevice, public output::FloatOutput {
                                                                           ^
src/lccomponent.h:43:87: error: invalid type in declaration before '{' token
 class LCFloatOutput : public Component, public UARTDevice, public output::FloatOutput {
                                                                                       ^
src/lccomponent.h:44:2: error: expected primary-expression before 'public'
  public:
  ^
src/lccomponent.h:44:2: error: expected '}' before 'public'
src/lccomponent.h:44:2: error: expected ',' or ';' before 'public'
src/lccomponent.h:49:31: error: expected ')' before '*' token
   LCFloatOutput(UARTComponent *parent, const char prefix)
                               ^
src/lccomponent.h:54:16: error: virt-specifiers in 'setup' not allowed outside a class definition
   void setup() override {
                ^
src/lccomponent.h:57:33: error: virt-specifiers in 'write_state' not allowed outside a class definition
   void write_state(float state) override {
                                 ^
src/lccomponent.h: In function 'void write_state(float)':
src/lccomponent.h:59:26: error: invalid use of 'this' in non-member function
     LCRelay::send_packet(this, pre, v);
                          ^
src/lccomponent.h:59:32: error: 'pre' was not declared in this scope
     LCRelay::send_packet(this, pre, v);
                                ^
src/lccomponent.h: At global scope:
src/lccomponent.h:61:1: error: expected declaration before '}' token
 };
 ^

which i can circumvent via not including lccomponent.h.

However i still dont get the switch to work :(

This is my config:

esphome:
  name: yolo
  platform: ESP8266
  board: esp01_1m
  includes:
    - lcrelay.h
#    - lccomponent.h

uart:
  id: uart0
  baud_rate: 19200
  tx_pin: GPIO1
  rx_pin: GPIO3

switch:
  - platform: gpio
    name: "Gong_LED"
    restore_mode: "ALWAYS_OFF"
    pin:
      number: 1
      inverted: True
  - platform: custom
    lambda: |-
      auto r1 = new LCRelay(id(uart0), 1);
      App.register_component(r1);
      return {r1};
    switches:
      - name: "relay"
        id: relay1

wifi:
  ssid: 'yolo'
  password: 'yolo'

# dont mess with the relay
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  password: 'yolo'

ota:
  password: 'yolo'

I also suspect that it should somehow be possible to run this w/o extra C code, but i also did not get that to run :/

  - platform: template
    id: relay_1
    name: relay
    turn_on_action:
      - uart.write: [0xA0, 0x01, 0x01, 0xA2]
    turn_off_action:
      - uart.write: [0xA0, 0x01, 0x00, 0xA1]
    optimistic: true

# another try...

  - platform: uart
    name: "UART A1"
    data: [0xA0, 0x01, 0x00, 0xA1]
  - platform: uart
    name: "UART A2"
    data: [0xA0, 0x01, 0x01, 0xA2]
nekromant commented 4 years ago

It looks like it's another update to esphome core. log.h may be dropped completely. Hold on, I'll fix it

nekromant commented 4 years ago

Fixed, just pull the latest update. And remember to flash nuvoton if you want buttons & leds supported