Jalle19 / eda-modbus-bridge

An HTTP/MQTT bridge for Enervent EDA ventilation units
GNU General Public License v3.0
14 stars 3 forks source link

Improve device compatibility with optional sensors/switches #106

Closed Jalle19 closed 6 months ago

Jalle19 commented 6 months ago

@juntta @ssalmela @JohanElmis @Ta802 @tomrosenback if you have time it would be great if you could test this branch. The goal is that features/sensors not supported by your particular device should appear as disabled sensors in Home Assistant.

In my case, the "Eco" switch is disabled, as well as control panel temperature, supply/exhaust fan speed, and of course all optional analog sensors since I don't have those.

ssalmela commented 6 months ago

Might be out of the original test scope, but I ran into this error when running

helmi 03 09:02:12 ubuntu systemd[1]: Stopped HTTP bridge for Enervent ventilation units with EDA automation.
helmi 03 09:02:12 ubuntu systemd[1]: eda-modbus-bridge.service: Consumed 3min 28.346s CPU time.
helmi 03 09:02:12 ubuntu systemd[1]: Started HTTP bridge for Enervent ventilation units with EDA automation.
helmi 03 09:02:12 ubuntu node[4713]: 2024-02-03T09:02:12.491Z [main] info: Opening Modbus connection to /dev/ttyUSB0, slave ID 1
helmi 03 09:02:12 ubuntu node[4713]: 2024-02-03T09:02:12.507Z [main] info: Connecting to MQTT broker at mqtt://192.168.52.68:1883
helmi 03 09:02:12 ubuntu node[4713]: 2024-02-03T09:02:12.508Z [main] info: Using MQTT broker authentication
helmi 03 09:02:12 ubuntu node[4713]: 2024-02-03T09:02:12.509Z [main] error: Failed to connect to MQTT broker: mqtt.connectAsync is not a function. Retrying in 5000 milliseconds
helmi 03 09:02:12 ubuntu node[4713]: 2024-02-03T09:02:12.511Z [http] info: Listening on http://0.0.0.0:8080
helmi 03 09:02:17 ubuntu node[4713]: 2024-02-03T09:02:17.515Z [main] error: Failed to connect to MQTT broker: mqtt.connectAsync is not a function. Retrying in 5000 milliseconds
Jalle19 commented 6 months ago

Run npm install again

ssalmela commented 6 months ago

Thanks 😀

helmi 03 10:22:05 ubuntu systemd[1]: Started HTTP bridge for Enervent ventilation units with EDA automation.
helmi 03 10:22:05 ubuntu node[5114]: 2024-02-03T10:22:05.634Z [main] info: Opening Modbus connection to /dev/ttyUSB0, slave ID 1
helmi 03 10:22:05 ubuntu node[5114]: 2024-02-03T10:22:05.649Z [main] info: Connecting to MQTT broker at mqtt://192.168.52.68:1883
helmi 03 10:22:05 ubuntu node[5114]: 2024-02-03T10:22:05.650Z [main] info: Using MQTT broker authentication
helmi 03 10:22:05 ubuntu node[5114]: 2024-02-03T10:22:05.699Z [http] info: Listening on http://0.0.0.0:8080
helmi 03 10:22:05 ubuntu node[5114]: 2024-02-03T10:22:05.705Z [main] info: Successfully connected to MQTT broker at mqtt://192.168.52.68:1883
helmi 03 10:22:11 ubuntu node[5114]: 2024-02-03T10:22:11.012Z [modbus] error: Failed to read coil address 18, length 4
helmi 03 10:22:11 ubuntu node[5114]: 2024-02-03T10:22:11.014Z [main] error: An exception occurred: TransactionTimedOutError: Timed out
Jalle19 commented 6 months ago

Okay, seems like those coils aren't readable either, even though they should be according to the register lists I have available. I'll push and update to make those optional as well, I'll let you know when there's something new to test!

ssalmela commented 6 months ago

Thanks, I am also trying to solve the issue for my particular device but need to learn things while doing. Modbus is all new to me.

I am currently trying to use mbpoll to figure out what is readable and how. Having issues reading pretty much any registers now so I need to understand the root cause and verify there is not something specially wrong with my environment.

A source mentioned that there could be limitations in reading one vs reading many at the same time. Or for writing. A lot to test.

@Jalle19 please note, I suspect a hardware issue in my setup as the version 2.5 no longer works either.

Jalle19 commented 6 months ago

Okay, if version 2.5.0 doesn't work either then something must be wrong with your setup. Perhaps you need to try a different RS-485 adapter?

Jalle19 commented 6 months ago

FWIW I moved the other "cooling/heating allowed" switches behind a feature flag as well, so feel free to try the latest version of this branch again.

ssalmela commented 6 months ago

Okay, if version 2.5.0 doesn't work either then something must be wrong with your setup. Perhaps you need to try a different RS-485 adapter?

Perhaps, I will buy one next week to not keep hitting the head in the wall. Unplugging USB and rebooting Enervent fixed it.

Now I get some data published to broker before (?) the read error for coil 18.

image

The homeassistant/# topics don't get published so I guess the read error terminates the script before those.

Jalle19 commented 6 months ago

Try the latest commit, it should not be reading coil 18 anymore in your case (LEGACY_EDA automation type)

ssalmela commented 6 months ago

Try the latest commit, it should not be reading coil 18 anymore in your case (LEGACY_EDA automation type)

It works, big thanks for your efforts. No errors logged and also homeassistant topic gets published.

image

I will double check the write situation after lunch.

ssalmela commented 6 months ago

The goal is that features/sensors not supported by your particular device should appear as disabled sensors in Home Assistant.

Yes, multiple sensors disabled:

image

ssalmela commented 6 months ago

It is possible we may need to also disable all the "write" functions for "Legacy EDA" v1.97 (unless it is just my device, waiting for reply from Enervent).

helmi 03 12:09:20 ubuntu node[1586]: 2024-02-03T12:09:20.538Z [mqtt] info: Received 22 on topic eda/settings/temperatureTarget/set
helmi 03 12:09:20 ubuntu node[1586]: 2024-02-03T12:09:20.539Z [mqtt] info: Updating setting temperatureTarget to 22
helmi 03 12:09:25 ubuntu node[1586]: node:internal/process/promises:288
helmi 03 12:09:25 ubuntu node[1586]:             triggerUncaughtException(err, true /* fromPromise */);
helmi 03 12:09:25 ubuntu node[1586]:             ^
helmi 03 12:09:25 ubuntu node[1586]: [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<TransactionTimedOutError>".] {
helmi 03 12:09:25 ubuntu node[1586]:   code: 'ERR_UNHANDLED_REJECTION'
helmi 03 12:09:25 ubuntu node[1586]: }
helmi 03 12:09:25 ubuntu node[1586]: Node.js v18.19.0
helmi 03 12:09:25 ubuntu systemd[1]: eda-modbus-bridge.service: Main process exited, code=exited, status=1/FAILURE
helmi 03 12:09:25 ubuntu systemd[1]: eda-modbus-bridge.service: Failed with result 'exit-code'.
helmi 03 12:09:25 ubuntu systemd[1]: eda-modbus-bridge.service: Consumed 3.430s CPU time.
helmi 03 12:09:30 ubuntu systemd[1]: eda-modbus-bridge.service: Scheduled restart job, restart counter is at 1.
helmi 03 12:09:30 ubuntu systemd[1]: Stopped HTTP bridge for Enervent ventilation units with EDA automation.
helmi 03 12:09:30 ubuntu systemd[1]: eda-modbus-bridge.service: Consumed 3.430s CPU time.
helmi 03 12:09:30 ubuntu systemd[1]: Started HTTP bridge for Enervent ventilation units with EDA automation.
helmi 03 12:09:31 ubuntu node[1601]: 2024-02-03T12:09:31.131Z [main] info: Opening Modbus connection to /dev/ttyUSB0, slave ID 1
helmi 03 12:09:31 ubuntu node[1601]: 2024-02-03T12:09:31.145Z [main] info: Connecting to MQTT broker at mqtt://192.168.52.68:1883
helmi 03 12:09:31 ubuntu node[1601]: 2024-02-03T12:09:31.146Z [main] info: Using MQTT broker authentication
helmi 03 12:09:31 ubuntu node[1601]: 2024-02-03T12:09:31.191Z [http] info: Listening on http://0.0.0.0:8080
helmi 03 12:09:31 ubuntu node[1601]: 2024-02-03T12:09:31.197Z [main] info: Successfully connected to MQTT broker at mqtt://192.168.52.68:1883
helmi 03 12:09:31 ubuntu node[1601]: 2024-02-03T12:09:31.848Z [main] info: MQTT scheduler started, will publish readings every 10 seconds
helmi 03 12:09:31 ubuntu node[1601]: 2024-02-03T12:09:31.849Z [mqtt] info: Subscribing to topic(s) eda/mode/+/set
helmi 03 12:09:31 ubuntu node[1601]: 2024-02-03T12:09:31.853Z [mqtt] info: Subscribing to topic(s) eda/settings/+/set
helmi 03 12:09:31 ubuntu node[1601]: 2024-02-03T12:09:31.861Z [main] info: Finished configuration Home Assistant MQTT discovery
helmi 03 12:16:32 ubuntu node[1601]: 2024-02-03T12:16:32.218Z [mqtt] info: Received ON on topic eda/mode/away/set
helmi 03 12:16:32 ubuntu node[1601]: 2024-02-03T12:16:32.219Z [mqtt] info: Updating mode away to true
helmi 03 12:16:37 ubuntu node[1601]: 2024-02-03T12:16:37.229Z [modbus] error: Failed to write coil address 1, value true
helmi 03 12:16:37 ubuntu node[1601]: node:internal/process/promises:288
helmi 03 12:16:37 ubuntu node[1601]:             triggerUncaughtException(err, true /* fromPromise */);
helmi 03 12:16:37 ubuntu node[1601]:             ^
helmi 03 12:16:37 ubuntu node[1601]: [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<TransactionTimedOutError>".] {
helmi 03 12:16:37 ubuntu node[1601]:   code: 'ERR_UNHANDLED_REJECTION'
helmi 03 12:16:37 ubuntu node[1601]: }
helmi 03 12:16:37 ubuntu node[1601]: Node.js v18.19.0
helmi 03 12:16:37 ubuntu systemd[1]: eda-modbus-bridge.service: Main process exited, code=exited, status=1/FAILURE
helmi 03 12:16:37 ubuntu systemd[1]: eda-modbus-bridge.service: Failed with result 'exit-code'.
Jalle19 commented 6 months ago

No, writing should definitely work even with that firmware version.

Ta802 commented 6 months ago

Starts nicely and it now shows exhaust fan speed and control panel temperature, but every other sensor is not getting value. Controls, configuration and diagnostics are working nicely.

With master branch all sensors are working.

I have Enervent Pingvin MDE

Pingvin eco EDE/MDE by Enervent Firmware: 1.42

2024-02-03T19:15:10.844Z [main] info: Opening Modbus connection to /dev/ttyUSB0, slave ID 1
2024-02-03T19:15:10.850Z [main] info: Connecting to MQTT broker at mqtt://192.168.80.4:1883
2024-02-03T19:15:10.850Z [main] info: Using MQTT broker authentication
2024-02-03T19:15:10.884Z [main] info: Successfully connected to MQTT broker at mqtt://192.168.80.4:1883
2024-02-03T19:15:14.431Z [main] info: MQTT scheduler started, will publish readings every 15 seconds
2024-02-03T19:15:14.432Z [mqtt] info: Subscribing to topic(s) eda/mode/+/set
2024-02-03T19:15:14.440Z [mqtt] info: Subscribing to topic(s) eda/settings/+/set
2024-02-03T19:15:14.445Z [main] info: Finished configuration Home Assistant MQTT discovery
ha ha3 ha2
Jalle19 commented 6 months ago

That makes no sense, not sure what's going on :/

Jalle19 commented 6 months ago

@Ta802 fixed in the latest commit

Ta802 commented 6 months ago

@Ta802 fixed in the latest commit

Yep. That fixed it for me.