-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add alarm support #32
Conversation
@tomrosenback I think we should treat the list of alarms in two different ways:
The problem with the current (albeit draft) implementation is that it doesn't allow for the same alarm to happen twice. IMO that's the normal case, e.g. you end up with the same "tuloilma kylmä" for example couple of times per winter when your LTO roller freezes shut. What do you think? |
For HTTP API, sure, I can agree with that, but isn´t the most recent alarm of any type the most interesting? What I mean is if say "tuloilma kylmä" has an active state, we are only interested in knowing that? I at least go and reset any errors after issue is fixed so the list of errors is mostly empty. Also in regards of dismissed or not, isn´t that basically the same thing, it takes a short while if the problem does not persist and the error goes away, so with that said as on MQTT side only interesting statuses are ON, and OFF (dismissed goes under this also). To conclude
@Jalle19 What do you think? Am I totally off? |
For the HTTP API I'm thinking something like this: "alarms": [
{
"code": "TE10",
"name": "TE10InletAfterHeaterCold",
"description": "Tuloilma LTO:n jälkeen kylmä",
"timestamp": "2022-01-18T12:58:05Z+0200"
},
{ ... },
] I.e. if there are no alarms then the list is empty.
Yes, I guess that's true. In this case I think it would make sense to use different approaches for the HTTP and MQTT APIs. MQTT is more limited in being simply "on" or "off", while HTTP can expose the alarm history as well (which is basically what you get on the control panel as well). |
HTTP API, ok with me. MQTT, ok. Will make adjustments accordingly, |
I'm not entirely sure what a Pandion machine looks like, but on my Pingvin it's easy to trigger an alarm by removing the LTO drum temporarily. |
Biggest difference I guess is size. |
Please test this out, have tested both HTTP and MQTT API and to me it looks ok now. |
Seems to throw unhandled promise rejections now, any idea? |
Can you show me the logs from when it happens? |
Doesn´t seem to happen anymore, no changes to code... |
`node eda-modbus-bridge.mjs --unhandled-rejections=warn -d /dev/ttyUSB0 --http false -m mqtt://localhost:1883 ... discovery messages ... node:internal/process/promises:265 [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 "#".] { Node.js v17.4.0 |
I think the rejection warnings is a bug in modbus-serial, but I haven't been able to track it down 🤷 |
c9f92fb
to
6d63622
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, thanks a lot! I'll test this locally ASAP and merge if it works.
You are welcome! I have mock tested both MQTT and HTTP locally, and it works, currently no alarms in my system so can´t tell if it really works, but if you have an easy way to test, please do to verify it with a "real" alarm. |
5a84809
to
708a826
Compare
Sorry, I accidentally pushed directly to your branch when I thought I was pushing to my remote. Didn't know I had write access :D |
Probably best if you force push your changes again |
No worries. |
What I can see your changes are not here anymore. |
You have started from my |
@tomrosenback I took your changes for a spin. Turns out my alarm history was full (all 20 slots populated). There were some weirdness with This has the added benefit of being (IMO) simpler since there's no |
Works, and looks good to me. My history is also full so can´t say what an empty slot would look like. Less is more, removing onlyActive and distinct with added benefits sounds very good. |
Easiest for now would be to merge this PR, and then add a new PR for your changes? Or then ditch this PR all together and just use your branch? Which ever is fine. |
Let's merge this so the author information is not lost, I'll then PR my changes on top of this. |
Adds alarm support for both MQTT and HTTP API.
Still work in progress, but please have a look and let me know if you want anything specific changed. Worth to note, first in this branch is untested.
Fixes issue #31 when merged