Giter Club home page Giter Club logo

Comments (15)

zewelor avatar zewelor commented on July 22, 2024 1

Hi

from error, it looks like you cannot reach mqtt server. Check ip and / or port. Be sure there is routing to given mqtt server. From ha config ip is "!secret mqtt_broker_ip", so check if its the same as provided in bt-mqtt-gateway config.

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024 1

Do you have mqtt server ( like mosquito ) on your network ?

from bt-mqtt-gateway.

bbbenji avatar bbbenji commented on July 22, 2024 1

Absolutely. There are a few add-ons which provide a mosquito broker. for example: https://www.home-assistant.io/addons/mosquitto/ & https://github.com/hassio-addons/addon-mqtt/blob/master/README.md

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024 1

You can try newest version, which should support home assistant auto discovery ( https://www.home-assistant.io/docs/mqtt/discovery/ ) or manually configure everything https://github.com/zewelor/bt-mqtt-gateway/wiki/Home-Assistant

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024 1

Host should point to mqtt server ip. It needs to send mqtt messages to it, and HA then reads it from mqtt server. It should work on stretch. From your log, it seems its working fine. Just configure mqtt sensors in HA and should be ready.

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024 1

Great it worked. There is some learning curve but after that its easy to add more and more stuff :D

from bt-mqtt-gateway.

ThirteenTX avatar ThirteenTX commented on July 22, 2024

Adding debug info if that helps (MAC omitted):
pi@mqtt-server:~/bt-mqtt-gateway $ sudo ./gateway.py -d
2019-06-30 19:39:44,349 INFO bt-mqtt-gw gateway.py:39: - Starting
2019-06-30 19:39:44,356 DEBUG bt-mqtt-gw.mqtt mqtt.py:23:init - Setting LWT to: bkrmmqqt/lwt_topic
2019-06-30 19:39:45,513 INFO bt-mqtt-gw.workers.mithermometer mithermometer.py:18:_setup - Adding 1 mithermometer devices
2019-06-30 19:39:45,516 DEBUG bt-mqtt-gw.workers.mithermometer mithermometer.py:20:_setup - Adding mithermometer device 'back_room' (XX:XX:XX:XX:XX:XX)
2019-06-30 19:39:45,520 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:60:register_workers - Added mithermometer config with a 2 seconds timeout
2019-06-30 19:39:45,524 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:65:register_workers - Added mithermometer worker with 300 seconds interval and a 35 seconds timeout
Traceback (most recent call last):
File "./gateway.py", line 43, in
manager.register_workers().start(mqtt)
File "/home/pi/bt-mqtt-gateway/workers_manager.py", line 101, in start
mqtt.callbacks_subscription(self._mqtt_callbacks)
File "/home/pi/bt-mqtt-gateway/mqtt.py", line 73, in callbacks_subscription
self.mqttc.connect(self.hostname, port=self.port)
File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 839, in connect
return self.reconnect()
File "/usr/local/lib/python3.5/dist-packages/paho/mqtt/client.py", line 962, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "/usr/lib/python3.5/socket.py", line 712, in create_connection
raise err
File "/usr/lib/python3.5/socket.py", line 703, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

from bt-mqtt-gateway.

ThirteenTX avatar ThirteenTX commented on July 22, 2024

So the IP in the config.yaml on the Pi zero is the IP of the bt-mqtt-gateway Pi zero.
In home assistant the "!secret mqtt_broker_ip" is also the IP address if the bt-mqtt-gateway Pi zero.
I added the port in home assistant just to test but the error is the same. I can ping the home assistant server from the Pi zero. Is that the right way to do it?

from bt-mqtt-gateway.

ThirteenTX avatar ThirteenTX commented on July 22, 2024

I have tried every combination now and none of them can get past the [Errno 111] Connection refused error.

from bt-mqtt-gateway.

ThirteenTX avatar ThirteenTX commented on July 22, 2024

Oh I thought that is what this is. Is that something I can load up in as an add-on in hass.io?

from bt-mqtt-gateway.

ThirteenTX avatar ThirteenTX commented on July 22, 2024

I'll give that a shot and see what I come up with and report back. Thanks to both of you for your time!

from bt-mqtt-gateway.

ThirteenTX avatar ThirteenTX commented on July 22, 2024

Okay I added this to my installation https://github.com/hassio-addons/addon-mqtt/blob/master/README.md

In the bt-mqtt-gateway config.yaml I set the host as the home assistant IP.

In home assistant I set up the configuration .yaml as:
mqtt:
broker: a0d7b954-mqtt
username: !secret mqtt_username
password: !secret mqtt_password
client_id: home-assistant
Per the instructions and set the relevant passwords.

In the add-on I set the config as follows:
{
"ssl": true,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem",
"broker": true,
"allow_anonymous": false,
"mqttusers": [
{
"username": "redacted user",
"password": "redacted pass",
"readonly": true,
"topics": [
"#"
]
}
]
}

I set the user and password in the bt-mqtt-gateway the same as it is in all of these configs.

The add-on logs show this repeatedly:

1562108372: New connection from "redacted ip" on port 1883.
1562108372: Client bt-mqtt-gateway already connected, closing old connection.
1562108372: New client connected from "redacted ip" as bt-mqtt-gateway (p2, c0, k60, u'redacted user').

Running the command "sudo ./gateway.py -d" on the bt-mqtt-gateway repeatedly gives:
2019-07-02 23:47:06,045 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:116:update_all - Updating all workers
2019-07-02 23:47:06,050 INFO bt-mqtt-gw.workers.mithermometer mithermometer.py:39:status_update - Updating 1 mithermometer devices
2019-07-02 23:47:06,054 DEBUG bt-mqtt-gw.workers.mithermometer mithermometer.py:42:status_update - Updating mithermometer device 'back_room' (redacted MAC)
2019-07-02 23:47:09,263 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:36:execute - Execution result of command MithermometerWorker.status_update: [{'payload': 22.6, 'topic': 'mithermometer/back_room/temperature'}, {'payload': 53.6, 'topic': 'mithermometer/back_room/humidity'}, {'payload': 100, 'topic': 'mithermometer/back_room/battery'}]
2019-07-02 23:52:05,997 INFO bt-mqtt-gw.workers.mithermometer mithermometer.py:39:status_update - Updating 1 mithermometer devices
2019-07-02 23:52:06,001 DEBUG bt-mqtt-gw.workers.mithermometer mithermometer.py:42:status_update - Updating mithermometer device 'back_room' (redacted MAC)
2019-07-02 23:52:09,116 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:36:execute - Execution result of command MithermometerWorker.status_update: [{'payload': 22.3, 'topic': 'mithermometer/back_room/temperature'}, {'payload': 54.7, 'topic': 'mithermometer/back_room/humidity'}, {'payload': 100, 'topic': 'mithermometer/back_room/battery'}]
2019-07-02 23:57:06,003 INFO bt-mqtt-gw.workers.mithermometer mithermometer.py:39:status_update - Updating 1 mithermometer devices
2019-07-02 23:57:06,008 DEBUG bt-mqtt-gw.workers.mithermometer mithermometer.py:42:status_update - Updating mithermometer device 'back_room' (redacted MAC)
2019-07-02 23:57:11,124 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:36:execute - Execution result of command MithermometerWorker.status_update: [{'payload': 22.8, 'topic': 'mithermometer/back_room/temperature'}, {'payload': 54.7, 'topic': 'mithermometer/back_room/humidity'}, {'payload': 100, 'topic': 'mithermometer/back_room/battery'}]
2019-07-03 00:02:06,008 INFO bt-mqtt-gw.workers.mithermometer mithermometer.py:39:status_update - Updating 1 mithermometer devices
2019-07-03 00:02:06,013 DEBUG bt-mqtt-gw.workers.mithermometer mithermometer.py:42:status_update - Updating mithermometer device 'back_room' (redacted MAC)
2019-07-03 00:02:11,135 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:36:execute - Execution result of command MithermometerWorker.status_update: [{'payload': 22.9, 'topic': 'mithermometer/back_room/temperature'}, {'payload': 54.1, 'topic': 'mithermometer/back_room/humidity'}, {'payload': 100, 'topic': 'mithermometer/back_room/battery'}]

So it seems like it is doing something. The issue I have now is how do I get that information into an entity in home assistant so I can track it?

from bt-mqtt-gateway.

ThirteenTX avatar ThirteenTX commented on July 22, 2024

One thing I have never been clear on. Is this supposed to run on its own? Like in the bt-mqyy-gateway config.yaml, is "host" on line supposed to point at itself for IP or another server?

from bt-mqtt-gateway.

ThirteenTX avatar ThirteenTX commented on July 22, 2024

Another thing. Does this not work on stretch lite? Is that my issue. None of this information ever seems to be useable in home assistant.

from bt-mqtt-gateway.

ThirteenTX avatar ThirteenTX commented on July 22, 2024

I really want to thank you again for bearing with me on this one! I am really new at this a I rewrote my SD card for this 6 times over and rebuilt my home assistant from scratch thinking that may be the issue. I probably have 30-40 hours in this but I learned a lot! I didn't see a "buy me a coffee" link but I would be glad to donate to the cause.

You were right I needed to make sensors in my sensor.yaml file. Here are the examples from mine that are now working as intended.

#MQTT

  • platform: mqtt
    name: "Back Room Temperature"
    state_topic: "bkrmmqqt/mithermometer/back_room/temperature"
    unit_of_measurement: '°C'
    device_class: "temperature"
  • platform: mqtt
    name: "Back Room Humidity"
    state_topic: "bkrmmqqt/mithermometer/back_room/humidity"
  • platform: mqtt
    name: "Back Room Battery"
    state_topic: "bkrmmqqt/mithermometer/back_room/battery"

The working config from the https://github.com/hassio-addons/addon-mqtt/blob/master/README.md add-on. I had to make changes like SSL to allow it to ingest messages.

{
"ssl": false,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem",
"broker": true,
"allow_anonymous": false,
"mqttusers": [
{
"username": "redacted",
"password": "redacted",
"readonly": false,
"topics": [
"#"
]
}
],
"log_level": "trace"
}

The config.yaml in bt-mqtt-gateway that worked for me.
host: x.x.x.x #home assistant IP
port: 1883
#username: redacted
#password: redacted
topic_prefix: bkrmmqqt # All messages will have that prefix added, remove if you dont need this.
client_id: bt-mqtt-gateway
availability_topic: lwt_topic

manager:
sensor_config:
topic: homeassistant
retain: true
topic_subscription:
update_all:
topic: homeassistant/status
payload: online
command_timeout: 35 # Timeout for worker operations. Can be removed if the default of 35 seconds is sufficient.
workers:
mithermometer:
args:
devices:
back_room: XX:XX:XX:XX:XX:XX <-- ommited MAC of Thermometer
topic_prefix: mithermometer
update_interval: 300

I hope these configs help some other lost person like me trying to do the same. Anyways you can close this one out as I am good :)

from bt-mqtt-gateway.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.