Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No MQ messages #23

Open
editter opened this issue Jul 15, 2021 · 2 comments
Open

No MQ messages #23

editter opened this issue Jul 15, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@editter
Copy link

editter commented Jul 15, 2021

Hello, I set up the addon in a second instance on a raspberry pi 3 and got the lock connected but I never see any MQ messages come through. I am not seeing the "MQTT connected" message in the logs so something isn't working but I'm not sure why. I get my birth/will messages when HA starts/stops so I know the MQ stuff is working but nothing from this addon. Thoughts?

Here is my entire configuration.yaml (note I did try adding the default_config entry in case that was important but I didn't see anything different)

configuration.yaml

config:
frontend:
hassio:
http:
webhook:

mqtt:
  discovery: false
  discovery_prefix: hass2
  birth_message:
    topic: "hass2/status"
    payload: "online"

  will_message:
    topic: "hass2/status"
    payload: "offline"
  broker: 192.168.1.55
  port: 1883
  client_id: hass2
  username: !secret mqtt_username
  password: !secret mqtt_password

I also see this in the logs and I am wondering if the service is not enabled but I'm not sure what Service it is referring to.

[08:12:28] ERROR: Got unexpected response from the API: Service not enabled
Debug MQTT
> [email protected] start
> node ./index.js
Monitor started
Server started
@editter
Copy link
Author

editter commented Jul 15, 2021

So I dug into this a little bit and I think I figured out the problem (I am not that familiar with the addon development so I might be wrong). The config.json services > mqtt:want will provide settings if it's an addon service, not just magically pulling it from configuration.yaml and because I am using an MQ broker on another machine it doesn't work for me.

My proposed solution would be to add config options and use that if the addon service isn't available. Thoughts?

config.json

"schema": {
  ...
     "mqtt_host": "str?",
      "mqtt_port": "port?",
      "mqtt_ssl": "bool?",
      "mqtt_username": "str?",
      "mqtt_password": "str?"
  }, 

start.sh

#!/usr/bin/env bashio

if ! bashio::services.available "mqtt"; then
    bashio::log.info "No internal MQTT service found, using addon config"
	export MQTT_HOST=$(bashio::config "mqtt_host")
	export MQTT_PORT=$(bashio::config mqtt "mqtt_port")
	export MQTT_SSL=$(bashio::config "mqtt_ssl")
	export MQTT_USER=$(bashio::config "mqtt_username")
	export MQTT_PASS=$(bashio::config "mqtt_password")
else
    bashio::log.info "MQTT service found, fetching credentials ..."
	export MQTT_HOST=$(bashio::services mqtt "host")
	export MQTT_PORT=$(bashio::services mqtt "port")
	export MQTT_SSL=$(bashio::services mqtt "ssl")
	export MQTT_USER=$(bashio::services mqtt "username")
	export MQTT_PASS=$(bashio::services mqtt "password")

fi
...

@kind3r kind3r added the enhancement New feature or request label Oct 14, 2021
@kind3r
Copy link
Owner

kind3r commented Oct 14, 2021

Indeed, it is designed to work with the MQTT addon provided by HA, to make it simple. I will put this on my todo list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants