Pretty new to ESPHome, setting my my first ESPHome configuration file, for a Arlec PC191HA power plug. It has a profile on Blakadder (Arlec Plug In Socket Power Monitoring Plug (PC191HA) Configuration for Tasmota) which includes a list of GPIO numbers, and the instruction to replace the WB2S module. Instead i have run cloudcutter for this device, and also used it to load an initial basic LibreTuya-esphome configuration. So far so good …
Now I have assembled a configuration from components on esphome.io website which I hope will duplicate the original functionality:
esphome:
name: "pc191ha-109"
libretuya:
board: wb2s
framework:
version: dev
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "HgoRlyg+sp+PXuiZ0h8fcSCxq+HxVp9hvmCAPwzMnW8="
ota:
# password: "eb9494d8b9ac189def0a76bc22bb638b"
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Pc191 Fallback Hotspot"
password: "v8ag08b0GTNj"
captive_portal:
web_server:
port: 80
# Example configuration entry
binary_sensor:
- platform: gpio
pin: 01
name: "pc191ha-109_button"
device_class: window
# Example configuration entry
light:
- platform: status_led
name: "Switch state"
pin: 14
# Example configuration entry
switch:
- platform: gpio
pin: 13
name: "pc191ha-109_switch"
# Example configuration entry for device BL0937 using inverted SEL pin functionality
sensor:
- platform: hlw8012
model: BL0937
sel_pin:
number: GPIO12
inverted: true
cf_pin: GPIO04
cf1_pin: GPIO05
current:
name: "BL0937 Current"
voltage:
name: "BL0937 Voltage"
power:
name: "BL0937 Power"
update_interval: 60s
Problem is that when I use the libreTuya-esphome (a fork of esphome) HA add-on to install, I get errors about the pin numbers. Not sure whether the issue comes from upstream (ESPHome) or libretuya-esphome - hence posting also to the larger community here.
With numeric pin numbers I get
INFO Reading configuration /config/libretuya-esphome/pc191ha-109.yaml...
Failed config
binary_sensor.gpio: [source /config/libretuya-esphome/pc191ha-109.yaml:38]
platform: gpio
Using raw pin numbers is ambiguous. Use either D1, A1 or P1 - all these are different pins! Refer to the docs for details.
pin: 1
name: pc191ha-109_button
device_class: window
light.status_led: [source /config/libretuya-esphome/pc191ha-109.yaml:45]
platform: status_led
name: Switch state
Using raw pin numbers is ambiguous. Use either D14, A14 or P14 - all these are different pins! Refer to the docs for details.
pin: 14 switch.gpio: [source /config/libretuya-esphome/pc191ha-109.yaml:51]
platform: gpio
Using raw pin numbers is ambiguous. Use either D13, A13 or P13 - all these are different pins! Refer to the docs for details.
pin: 13
name: pc191ha-109_switch
however all the docs I have found so far seem to use GPIO pin numbers, most often without an D, A or P prefix !!! Which doc is this referring to ?
I’ve googled for “Using raw pin numbers is ambiguous”, but no results.
If I prefix them all with “GPIO” I get
Compiling /data/pc191ha-109/.pioenvs/pc191ha-109/src/main.cpp.o
src/main.cpp: In function 'void setup()':
src/main.cpp:214:45: error: 'PIN_FUNCTION_P01' was not declared in this scope
libretuya_arduinointernalgpiopin->set_pin(PIN_FUNCTION_P01);
^
src/main.cpp:237:47: error: 'PIN_FUNCTION_P14' was not declared in this scope
libretuya_arduinointernalgpiopin_2->set_pin(PIN_FUNCTION_P14);
^
src/main.cpp:276:47: error: 'PIN_FUNCTION_P13' was not declared in this scope
libretuya_arduinointernalgpiopin_3->set_pin(PIN_FUNCTION_P13);
^
src/main.cpp:351:47: error: 'PIN_FUNCTION_P12' was not declared in this scope libretuya_arduinointernalgpiopin_4->set_pin(PIN_FUNCTION_P12);
^
src/main.cpp:356:47: error: 'PIN_FUNCTION_P04' was not declared in this scope libretuya_arduinointernalgpiopin_5->set_pin(PIN_FUNCTION_P04);
^
src/main.cpp:361:47: error: 'PIN_FUNCTION_P05' was not declared in this scope libretuya_arduinointernalgpiopin_6->set_pin(PIN_FUNCTION_P05);
^
*** [/data/pc191ha-109/.pioenvs/pc191ha-109/src/main.cpp.o] Error 1
========================= [FAILED] Took 18.15 seconds =========================
One of the documentation pages (can’t remember which one) says that ESPHome has a table of GPIO to actual physical pin numbers - maybe this hasn’t been setup in libreTuya-esphome for the new modules ?
Any other suggestions please.