Closed visa69 closed 1 year ago
And you're sure you have an MQTT broker running on 192.168.2.222?
Yes, MQTT broker is working on 192.168.2.222. I have my electric meters also in the same broker and I get values. I can also publish and subscribe manually from HA to broker using mosquitto_sub and pub. I have two possible cause for the error: 1) My broker is using mqtt version 3.1.1. Version 5 is not possible at the moment. 2) There is no reference ground terminal in my modbus controller and it is possible that it can not get any readable messsages from Enervent.
Installed mosquitto broker as add-on. Service is now found by the script.
[16:08:01] INFO: MQTT service found, using service config Opening serial connection to /dev/ttyAMA0, slave ID 1 Connecting to MQTT broker at mqtt://core-mosquitto:1883 Using MQTT broker authentication Failed to connect to MQTT broker: Timed out
Not sure why it doesn't work, feels like there's something wrong with your setup if even the Mosquitto addon doesn't work.
@tomrosenback any ideas here?
I tried installing the Mosquitto addon and everything worked out of the box :thinking:
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[08:57:28] INFO: MQTT service found, using service config
Opening serial connection to /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AG0KBDA8-if00-port0, slave ID 1
Connecting to MQTT broker at mqtt://core-mosquitto:1883
Using MQTT broker authentication
Listening on http://0.0.0.0:8080
MQTT scheduler started, will publish readings every 15 seconds
Subscribing to topic(s) eda/mode/+/set
Subscribing to topic(s) eda/settings/+/set
Publishing Home Assistant auto-discovery configuration for sensor "freshAirTemperature"...
Publishing Home Assistant auto-discovery configuration for sensor "supplyAirTemperature"...
Publishing Home Assistant auto-discovery configuration for sensor "supplyAirTemperatureAfterHeatRecovery"...
Publishing Home Assistant auto-discovery configuration for sensor "exhaustAirTemperature"...
Publishing Home Assistant auto-discovery configuration for sensor "wasteAirTemperature"...
Publishing Home Assistant auto-discovery configuration for sensor "exhaustAirHumidity"...
Seems like there is some limitations within the system as the addon aswell is not working
Yeah I just updated the addon to 1.3.0 and noticed that it needed a minor fix in order to start at all, so I published 1.3.1 a few minutes ago.
I update the addon, but still same issue appears, the MQTT Mosquitto broker version is 6.2.0 .
s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started [21:43:31] INFO: MQTT service found, using service config Opening serial connection to /dev/ttyUSB0, slave ID 1 Connecting to MQTT broker at mqtt://core-mosquitto:1883 Using MQTT broker authentication Failed to connect to MQTT broker: Timed out
btw how to specify the device? Now I'm using the default value /dev/ttyUSB0 edit: should I use device id: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AQ024BLR-if00-port0
You need to check the correct path from Home Assistant's "system overview" page. It's somewhere under settings. ttyUSB0 is fine until you have more than onr USB serial device.
Any ideas how to continue or what I should try next find a solution to this problem?
Does it work if you restart the eda-modbus-bridge addon?
No it doesn't help, I reinstall both Mosquitto MQTT broker and eda-modbus-addon. Last row in the log is the same, Failed to connect to MQTT broker: Timed out. I'm running HassOS and all services are running in HA. Is there any way or tools to verify modbus communication between HA and ventilation unit?
You can use the HTTP API to query data from the ventilation unit. First you need to enable it in the addon configuration, then browse to x.x.x.x:yyyy where x.x.x.x is your Home Assistant IP address and yyyy is the HTTP port specified in the addon configuration.
Now you need to give more details, how to get data out of HTTP API? HTTP API enabled and by browser I get "text eda-modbus-bridge"
@Jar1H do you see anything in the Mosquitto addon logs when the timeout occurs?
In debug mode the log is a bit messy but these lines shows up when starting the add-on: "2023-04-11T11:13:53+03:00" level=debug msg="checking auth cache for addons" time="2023-04-11T11:13:53+03:00" level=debug msg="to auth record: [97 117 116 104 45 97 100 100 111 110 115 45 84 104 101 49 84 104 101 105 90 97 101 114 111 111 100 101 105 108 111 51 117 84 104 117 83 104 101 105 99 101 105 118 57 73 103 104 52 65 110 97 52 97 105 99 97 101 52 97 105 82 97 50 97 104 113 117 49 105 117 110 103 97 105 84 218 57 163 238 94 107 75 13 50 85 191 239 149 96 24 144 175 216 7 9]\n" time="2023-04-11T11:13:53+03:00" level=debug msg="found in cache: addons" time="2023-04-11T11:14:09+03:00" level=debug msg="checking acl cache for mqtt" time="2023-04-11T11:14:09+03:00" level=debug msg="to auth record: [97 99 108 45 109 113 116 116 45 102 114 105 103 97 116 101 47 115 116 97 116 115 45 102 114 105 103 97 116 101 45 50 218 57 163 238 94 107 75 13 50 85 191 239 149 96 24 144 175 216 7 9]\n" time="2023-04-11T11:14:09+03:00" level=debug msg="Superuser check with backend Files" time="2023-04-11T11:14:09+03:00" level=debug msg="Superuser check with backend HTTP" time="2023-04-11T11:14:09+03:00" level=debug msg="http request approved for mqtt" time="2023-04-11T11:14:09+03:00" level=debug msg="superuser mqtt acl authenticated with backend HTTP" time="2023-04-11T11:14:09+03:00" level=debug msg="setting acl cache (granted = true) for mqtt" time="2023-04-11T11:14:09+03:00" level=debug msg="to auth record: [97 99 108 45 109 113 116 116 45 102 114 105 103 97 116 101 47 115 116 97 116 115 45 102 114 105 103 97 116 101 45 50 218 57 163 238 94 107 75 13 50 85 191 239 149 96 24 144 175 216 7 9]\n" time="2023-04-11T11:14:09+03:00" level=debug msg="Acl is true for user mqtt" time="2023-04-11T11:14:09+03:00" level=debug msg="checking acl cache for mqtt" time="2023-04-11T11:14:09+03:00" level=debug msg="to auth record: [97 99 108 45 109 113 116 116 45 102 114 105 103 97 116 101 47 115 116 97 116 115 45 102 114 105 103 97 116 101 45 49 218 57 163 238 94 107 75 13 50 85 191 239 149 96 24 144 175 216 7 9]\n" time="2023-04-11T11:14:09+03:00" level=debug msg="Superuser check with backend Files" time="2023-04-11T11:14:09+03:00" level=debug msg="Superuser check with backend HTTP" time="2023-04-11T11:14:09+03:00" level=debug msg="http request approved for mqtt" time="2023-04-11T11:14:09+03:00" level=debug msg="superuser mqtt acl authenticated with backend HTTP" time="2023-04-11T11:14:09+03:00" level=debug msg="setting acl cache (granted = true) for mqtt" time="2023-04-11T11:14:09+03:00" level=debug msg="to auth record: [97 99 108 45 109 113 116 116 45 102 114 105 103 97 116 101 47 115 116 97 116 115 45 102 114 105 103 97 116 101 45 49 218 57 163 238 94 107 75 13 50 85 191 239 149 96 24 144 175 216 7 9]\n" time="2023-04-11T11:14:09+03:00" level=debug msg="Acl is true for user mqtt"
Looks like normal "background noise", no trace of a connection from any client
@Jar1H can you post your Mosquitto addon configuration?
Here is the configurations:
logins: [] require_certificate: false certfile: fullchain.pem keyfile: privkey.pem customize: active: false folder: mosquitto debug: false
And Network config: 1883 Normal MQTT 1884 MQTT over WebSocket 8883 Normal MQTT with SSL 8884 MQTT over WebSocket with SSL
The MQTT broker is working properly
Is there something basic misunderstanding what I do wrong during the installation? Yesterday I try the clean HA installation on my laptop (inside wm), and same problem occured. looks like i need "for dummies" instructions :)
There's nothing special to do, it should just work. I haven't been able to reproduce this myself.
how does this add-on behave if there is a fault on the Enervent side?
It will fail to publish any readings to the MQTT broker
Here is my Enervent addon configuration
modbus:
device: /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
slave: 1
mqtt:
host: ip-of-your-MQTT-broker
ssl: false
port: 1883
username: ***************
password: ***************
publish_interval: 60
http:
enabled: false
listen_address: 0.0.0.0
listen_port: 8080
The addon will not care as such if the Modbus communication is working or not, at least not in regards of the ability to connect to the MQTT broker.
In my config you see in the mqtt > host section "ip-of-your-MQTT-broker", the IP to enter here you can find at the bottom of https://my.home-assistant.io/redirect/network page in the Network adapter section
Please check your configuration and test out.
Thanks, but unfortunately the problem is still there. In the Log-file there is always same text: Connecting to MQTT broker at mqtt://core-mosquitto:1883, even I specified the host manually? I try an external (outside of HA) MQTT broker and try to find some progress.
Yeah, unfortunately it's not possible to specify an external broker as long as the Mosquitto addon is installed, see https://github.com/Jalle19/home-assistant-addon-repository/issues/18
I set up external MQTT broker, now log file looks like that: s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started [20:59:07] INFO: No internal MQTT service found, using addon config Opening serial connection to /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AQ024BLR-if00-port0, slave ID 1 Connecting to MQTT broker at mqtt://192.168.0.13:{"host":"192.168.0.13","ssl":false,"port":1883,"username":"*","password":"***","publish_interval":60} Using MQTT broker authentication Failed to connect to MQTT broker: Timed out
I can't really help anymore without being able to reproduce this :/ What kind of device do you run Home Assistant on?
I'm running HassOS in Rasberry PI4, For my understanding the MQTT Broker works normally, I let you know if I find a solution or reason for this behavior.
Does the Pi use ethernet or wifi?
Ethernet connection only
Were you able to verify that the software is able to comnunicate with the ventilation unit? I'm wondering if a Modbus "connect" could end up blocking the event loop so badly that the MQTT client refuses to connect.
I could not get a tested connection to the ventilation device. It is beyond my knowledge and I need a bit more specific advice how to do it.
advice how to test the connection?
I had at first Raspberry pi 2 where this problem occurred first time. Then I made modbus config to the HA config file and modbus worked for me. Then I change Raspberry to x86 platform and try with this and got same problem. So it is not HW problem. I think it's more like authentication problem.
@visa69 do you have any ideas what would be next step to try to fix this? I'm using mosquitto MQTT broker on default config and same for the Enervent EDA Modbus Bridge. I created own user for mqtt in HA.
@visa69 @Jar1H can you update your addon version to 1.3.2 (click the triple dot menu and then Check for updates in the addon store if you don't see the update), it has some changes to error messages and logging which should highlight what's actually going on here.
I believe the "Timed out" message is not actually from connecting to the broker but from trying to read values from Modbus. Please post new logs once you've updated to 1.3.2.
Hi, here is the log after the update:
s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started [18:34:19] INFO: MQTT service found, using service config Opening serial connection to /dev/ttyUSB0, slave ID 1 Connecting to MQTT broker at mqtt://core-mosquitto:1883 Using MQTT broker authentication Successfully connected to MQTT broker at mqtt://core-mosquitto:1883 Unknown exception occurred: Timed out undefined
Okay, the error trace is apparently still missing but it seems like the "timed out" comes from the Modbus client. You need to doublecheck your connection to the ventilation unit.
Done, is there any ways to test the connection manually? Or example how to configure HA (configuration.yaml) to read one value from ventilation unit, modbus config etc. I tried but didn't succeed.
Yes, you can add individual Modbus registers as sensors in Home Assistant. There's probably some good guides on it if you search around. There's a register list as a PDF in this repository.
Although to be honest, if you connect it correctly to a supported ventilation unit it should just work 🤷 Perhaps you could try a different RS-485 adapter?
Cheap RS485 connectors can be tricky, some work, some don't. Have you tried swapping A/B wires?
@tomrosenback i will try this... when I changed the A/B wires and it works! I have checked the connection several times, changed the wire and now when I changed the wires to a cross it started to work. Feel bit stupid, but I Blindly trusted the RS-485 adapter and its markings, apparently they are crossed? @Jalle19 @tomrosenback thanks for your support!
It's a common source of confusion since the correct way to connect TX and RX is in a crossover - TX to RX and vice versa. Some adapters use A and B instead which makes it hard to know which is which.
Glad you got it working, I'll close this issue now 👍
I added a troubleshooting section: https://github.com/Jalle19/eda-modbus-bridge/commit/dfd38034f2e52f23b03a1bad4ed08cb942c93011
@visa69 please let us know if swapping your A and B data cables works for you too.
Both, localhost and external broker fails.
[17:25:44] INFO: No internal MQTT service found, using addon config Opening serial connection to /dev/serial0, slave ID 1 Connecting to MQTT broker at mqtt://localhost:{"host":"localhost","ssl":false,"port":1883,"username":"*","password":"**","publish_interval":5} Using MQTT broker authentication Failed to connect to MQTT broker: connect ECONNREFUSED 127.0.0.1:1883
[17:31:48] INFO: No internal MQTT service found, using addon config Opening serial connection to /dev/serial0, slave ID 1 Connecting to MQTT broker at mqtt://192.168.2.222:{"host":"192.168.2.222","ssl":false,"port":1883,"username":"*","password":"**","publish_interval":5} Using MQTT broker authentication Failed to connect to MQTT broker: Timed out