syssi / esphome-jk-bms

ESPHome component to monitor and control a Jikong Battery Management System (JK-BMS) via UART-TTL or BLE
Apache License 2.0
474 stars 161 forks source link

allow anonymous mqtt, eg. without username/passwort #237

Closed abc2006 closed 1 year ago

syssi commented 1 year ago

It looks like the username and passwort parameter is optional: https://esphome.io/components/mqtt.html

Feel free to remove these lines.

abc2006 commented 1 year ago

Hi, thanks for your answer. Unfortunately, this does not work. Should have mentioned i tried that before:

stephan@stephan-desktop-neu:~/esp32/esphome-jk-bms$ esphome run esp32-example.yaml
INFO Reading configuration esp32-example.yaml...
ERROR Error while reading config: Invalid YAML syntax:

Secret 'mqtt_username' not defined
  in "esp32-example.yaml", line 38, column 13:
      username: !secret mqtt_username
                ^
stephan@stephan-desktop-neu:~/esp32/esphome-jk-bms$ cat secrets.yaml 
wifi_ssid: SNSH
wifi_password: thisisascecretpassword 
mqtt_host: 192.168.0.25

stephan@stephan-desktop-neu:~/esp32/esphome-jk-bms$ 
abc2006 commented 1 year ago

leaving empty also does not work:

`stephan@stephan-desktop-neu:~/esp32/esphome-jk-bms$ cat secrets.yaml 
wifi_ssid: SNSH
wifi_password: thisisascecretpassword 
mqtt_host: 192.168.0.25
mqtt_username:
mqtt_password:

stephan@stephan-desktop-neu:~/esp32/esphome-jk-bms$ esphome run esp32-example.yaml
INFO Reading configuration esp32-example.yaml...
INFO Updating https://github.com/syssi/esphome-jk-bms.git@main
Failed config

mqtt: [source esp32-example.yaml:37]
  broker: !secret mqtt_host

  string value is None.
  username: 

  string value is None.
  password: 
  id: mqtt_client
stephan@stephan-desktop-neu:~/esp32/esphome-jk-bms`
syssi commented 1 year ago

You have to reduce the mqtt component section from:

mqtt:
  broker: !secret mqtt_host
  username: !secret mqtt_username
  password: !secret mqtt_password
  id: mqtt_client

to

mqtt:
  broker: !secret mqtt_host
  id: mqtt_client

This builds fine.

abc2006 commented 1 year ago

Ah great, thanks!