ycardon / gigaset-elements-proxy

a simple web and MQTT bridge with gigaset-elements APIs (no more maintained)
GNU General Public License v3.0
18 stars 5 forks source link

Hassio Addon: not connecting to Mosquitto Addon when using loopback IP/Host #19

Open Pe-MaKer opened 5 years ago

Pe-MaKer commented 5 years ago

The Mosquitto Broker does not receive MQTT messages from the Gigaset elements proxy.

Setup: Home Assistant 0.100.1 Hassio Supervisor 189 HassOS 2.11 Gigaset Elements Proxy Add-on 1.2 Mosquitto Broker Add-on 5.1

I created a new user "gigaset" in the HA user administration, which I also used in the add-on config of the element Proxy:

{
  "email": "my@email.address",
  "password": "password;)",
  "check_events_interval": 10,
  "mqtt_url": "mqtt://localhost:1883",
  "mqtt_options": {
    "clientId": "gigaset",
    "username": "gigaset",
    "password": "donttellanybody"
  },
  "allow_unknown_events": false
}

The log of the proxy doesn't show any (e.g. authentication) error:

[Tue Oct 22 2019 10:27:26] [LOG]    acquired event: {"id":"9fca34723794fd141241b359e55c41ee2b7976ee","state":"ok","ts":"1571732840809","type":"close","o":{"frontendTags":{"room":{"roomName":"Arbeitszimmer"}},"friendly_name":"Arbeitszimmerfenster","id":"0335ab9b16","factoryType":"umos","type":"um01","umosConfiguredType":{"mainType":"window","subType":"regular"},"room":{"id":75665,"friendlyName":"Arbeitszimmer"}},"source_id":"BB4BC9AAA262EEABA32021A066F0B043","source_name":"base","source_type":"basestation","state_pre":"ok"}
[Tue Oct 22 2019 10:27:26] [LOG]    event sent as mqtt_topic: gigaset/Arbeitszimmerfenster, value: false

But when I subscribe to the topic "gigaset/Arbeitszimmerfenster" or "gigaset/#", nothing happens. No messages, no error messages in the Mosquitto logs. Just nothing.

h4nc commented 5 years ago

Try mqtt://localhost instead of mqtt://localhost:1883

Pe-MaKer commented 5 years ago

I've tried it without port number with the same result. No messages and unfortunately not even an error message.

h4nc commented 5 years ago

You could also try mqtt://yourlocalipadress. But it seems like there is a different issue. I'm sure @ycardon will help you.

Pe-MaKer commented 5 years ago

After changing the mqtt_url to my local hostname, it looks promising:

19-10-22 13:48:42 INFO (SyncWorker_15) [hassio.docker.addon] Start Docker add-on d8fd2d64/armv7-addon-gigaset with version 1.2
19-10-22 13:48:47 INFO (MainThread) [hassio.auth] Auth request from core_mosquitto for gigaset
19-10-22 13:48:48 INFO (MainThread) [hassio.auth] Success login from gigaset

:)

"localhost" and "127.0.0.1" (as documented) did not work. One have to specify at least the Hostname or IP of the broker.

ycardon commented 4 years ago

Well, it does work with localhost when you are not using it as a Hassio add-on (which uses docker networking: localhost from within a docker container is not the "host" localhost)

I keep the issue open until I put some works in the doc !

h4nc commented 4 years ago

(which uses docker networking: localhost from within a docker container is not the "host" localhost)

@ycardon could you explain that bit more? Is it not the „host“ localhost because it’s not in the same container?

ycardon commented 4 years ago

yes, it could be clearer :)

When you are using docker, you must consider that each container is a (virtual) server.

Better explanation ?

h4nc commented 4 years ago

Better explanation ?

Perfect explanation, thank you!