LordMike / MBW.BlueRiiot2MQTT

Utility to map between Blue Riiots pool API, and Home Assistant MQTT
47 stars 2 forks source link

Can't get use of secrets.yaml to work #63

Closed sddgit closed 2 years ago

sddgit commented 2 years ago

I'm sure this is something I'm doing wrong (pretty new to HA), but I can’t get the mqtt username and password to work if I put them in the secrets.yaml file. My config currently looks like this, and it works (I manually added the mqtt username to HA for now):

MQTT:  
  Server: 192.168.0.240. 
  Port: 1883
  Username: mqtt
  Password: mqtt
  ClientId: blueriiot2mqtt
BlueRiiot:
  Username: '!secret blueriiot_username'
  Password: '!secret blueriiot_password'
  Language: en
  DiscoveryInterval: '12:00:00'
  UpdateInterval: '01:00:00'
  UpdateIntervalWhenAllDevicesAsleep: '08:00:00'
  ReportUnchangedValues: false
  EnableSchedule: true
HASS:
  DiscoveryPrefix: homeassistant
  TopicPrefix: blueriiot
  EnableHASSDiscovery: true

The username and password for the BlueRiiot login works fine in this format. If I change the mqtt username and password so it looks like this:

MQTT:  
  Server: 192.168.0.240. 
  Port: 1883
  Username: '!secret blueriiot_mqtt_username'
  Password: '!secret blueriiot_mqtt_password'
  ClientId: blueriiot2mqtt
BlueRiiot:
  Username: '!secret blueriiot_username'
  Password: '!secret blueriiot_password'
  Language: en
  DiscoveryInterval: '12:00:00'
  UpdateInterval: '01:00:00'
  UpdateIntervalWhenAllDevicesAsleep: '08:00:00'
  ReportUnchangedValues: false
  EnableSchedule: true
HASS:
  DiscoveryPrefix: homeassistant
  TopicPrefix: blueriiot
  EnableHASSDiscovery: true

with this in secrets.yaml:

blueriiot_mqtt_username: xxxxxxx
blueriiot_mqtt_password: xxxxxxx

I get mqtt authentication errors. Must be some sort off syntax error I don't understand. Help appreciated!

LordMike commented 2 years ago

I'm not familiar with these secrets, but if your first example works fine, I would assume the second to work as well.

I can see that HASS has a few debugging options you can try: https://www.home-assistant.io/docs/configuration/secrets/

Maybe the logs can tell you more about why it works in one place, but not the other.

sddgit commented 2 years ago

Thanks for the link. I I tried the logging option. I don’t know how to run the script - that command isn’t found using the Terminal/SSH add-on’s Terminal session. The log only showed secrets being retrieved from my other components, and not even the Blueriiot username and password, even though that clearly works. However, I reinstated the !secret syntax for the mqtt username and password and it started working. I had tried multiple times previously, with a few restarts, to no avail. Go figure!

LordMike commented 2 years ago

Eh - sometimes minor invisible stuff like spaces before or after .. anything .. will break it.. :)

I'll close this issue. :)