libretiny-eu / libretiny

PlatformIO development platform for IoT modules
http://docs.libretiny.eu/
MIT License
415 stars 62 forks source link

MOES WS-B-US 2 Button Smart Switch did not create other components such as binary_sensor, light, etc. in HA? #277

Closed percy10442 closed 7 months ago

percy10442 commented 7 months ago

Why is it that after refreshing ESPhome, only two Relay components are generated, and other components like binary_sensor, light, etc., are not generated?

螢幕擷取畫面 2024-04-10 090122
esphome:
  name: upk2esphome-bk7231n
  name_add_mac_suffix: False

bk72xx:
  board: generic-bk7231n-qfn32-tuya

logger:

web_server:

captive_portal:

mdns:

api:

ota:

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

button:
  - platform: restart
    name: Restart

debug:
  update_interval: 30s

text_sensor:
  - platform: debug
    reset_reason:
      name: Reset Reason
  - platform: libretiny
    version:
      name: LibreTiny Version

sensor:
  - platform: uptime
    name: Uptime

output:
  - platform: gpio
    id: output_led_1
    pin:
      number: P14
      inverted: true
  - platform: gpio
    id: output_led_2
    pin:
      number: P20
      inverted: true

light:
  - platform: binary
    id: light_switch_1
    output: output_led_1
  - platform: binary
    id: light_switch_2
    output: output_led_2

binary_sensor:
  - platform: gpio
    id: binary_switch_1
    pin:
      number: P23
      inverted: true
      mode: INPUT_PULLUP
    on_press:
      then:
        - switch.toggle: switch_1
  - platform: gpio
    id: binary_switch_2
    pin:
      number: P28
      inverted: true
      mode: INPUT_PULLUP
    on_press:
      then:
        - switch.toggle: switch_2

switch:
  - platform: gpio
    id: switch_1
    name: Relay 1
    pin: P24
    on_turn_on:
      - light.turn_off: light_switch_1
    on_turn_off:
      - light.turn_on: light_switch_1
  - platform: gpio
    id: switch_2
    name: Relay 2
    pin: P26
    on_turn_on:
      - light.turn_off: light_switch_2
    on_turn_off:
      - light.turn_on: light_switch_2
Cossid commented 7 months ago

This has nothing to do with LibreTiny. This is completely your ESPHome config. If you don't assign a name: property to entities, they are not exposed over the API.

percy10442 commented 7 months ago

Understood, thank you for your clarification.