Skip to content
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

The extremest edge case: homebridge-p1 crashes when gas meter is removed #78

Closed
wimleers opened this issue Jul 5, 2023 · 4 comments
Closed

Comments

@wimleers
Copy link
Contributor

wimleers commented Jul 5, 2023

Yesterday, my gas meter was removed. I realize this is a pretty extreme edge case 🤓 😅

But this did trigger this plugin crashing:

[7/5/2023, 11:17:13 AM] [P1] warning: TypeError: Cannot read properties of undefined (reading 'consumption')
    at Gas.check (/Users/admin/Desktop/homebridge-p1/lib/P1Service.js:175:36)
    at Gas.check (/Users/admin/Desktop/homebridge-p1/lib/P1Accessory.js:27:18)
    at P1Platform.onData (/Users/admin/Desktop/homebridge-p1/lib/P1Platform.js:211:18)
    at P1Client.<anonymous> (/Users/admin/Desktop/homebridge-p1/lib/P1Platform.js:117:40)
    at P1Client.emit (node:events:513:28)
    at P1Client.parseTelegram (/Users/admin/Desktop/homebridge-p1/lib/P1Client.js:682:12)
    at ReadlineParser.<anonymous> (/Users/admin/Desktop/homebridge-p1/lib/P1Client.js:424:51)
    at ReadlineParser.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:293:11)

A simple reboot fixes it though:

[7/5/2023, 11:18:25 AM] [P1] Restarting child bridge...
[7/5/2023, 11:18:25 AM] Got SIGTERM, shutting down child bridge process...
[7/5/2023, 11:18:30 AM] [P1] Child bridge process ended
[7/5/2023, 11:18:30 AM] [P1] Process Ended. Code: 143, Signal: null
[7/5/2023, 11:18:37 AM] [P1] Restarting Process...
[7/5/2023, 11:18:37 AM] [P1] Launched child bridge with PID 53305
[7/5/2023, 11:18:37 AM] The plugin "homebridge-p1" requires Node.js version of ^18.14.1 which does not satisfy the current Node.js version of v18.14.0. You may need to upgrade your installation of Node.js - see https://homebridge.io/w/JTKEF
[7/5/2023, 11:18:37 AM] Registering platform 'homebridge-p1.P1'
[7/5/2023, 11:18:37 AM] [P1] Loaded homebridge-p1 v1.3.4-0 child bridge successfully
[7/5/2023, 11:18:37 AM] Loaded 3 cached accessories from cachedAccessories.0E981C41ADC8.
[7/5/2023, 11:18:37 AM] [P1] homebridge-p1 v1.3.4-0, node v18.14.0, homebridge v1.6.0, homebridge-lib v6.3.11
[7/5/2023, 11:18:37 AM] [P1] warning: recommended version: node v18.14.2 LTS
[7/5/2023, 11:18:37 AM] Homebridge v1.6.0 (HAP v0.11.0) (P1) is running on port 54199.
[7/5/2023, 11:18:38 AM] [P1] hardware: Mac mini (M1, 2020)
[7/5/2023, 11:18:38 AM] [P1] os: macOS Monterey 12.3.1 (21E258)
[7/5/2023, 11:18:38 AM] [P1] restored 3 accessories from cache
[7/5/2023, 11:18:39 AM] [P1] connected to 192.168.0.219:23
[7/5/2023, 11:18:39 AM] [P1] warning: latest version: homebridge-p1 v1.3.9
[7/5/2023, 11:18:39 AM] [P1] warning: ignoring invalid telegram
[7/5/2023, 11:18:40 AM] [VELUX safe] Setting switch to false
[7/5/2023, 11:18:40 AM] [P1] FLU5\253770234_A v5.0
[7/5/2023, 11:18:40 AM] [P1] Electricity: Electric Current: set to 17.32 A (from 17.47 A)
[7/5/2023, 11:18:40 AM] [P1] Electricity Delivered: Total Consumption: set to 2130.054 kWh (from 2130.035 kWh)
[7/5/2023, 11:18:40 AM] [P1] Electricity Delivered: Total Consumption Normal: set to 1525.085 kWh (from 1525.066 kWh)
[7/5/2023, 11:18:40 AM] [P1] Electricity Delivered: Current Consumption: set to 4205 W (from 4242 W)
@ebaauw
Copy link
Owner

ebaauw commented Jul 5, 2023

I don’t see a crash, just a warning message (with stack trace)?

Indeed, removing a meter isn’t a use case I had anticipated, but it’s quite easy to prevent the TypeError.

BTW you’re running an old beta version of Homebridge P1.

@wimleers
Copy link
Contributor Author

wimleers commented Jul 6, 2023

BTW you’re running an old beta version of Homebridge P1.

Yes, I am, because almost every release you make bumps the minimum node version — so I can't update plugins through the Homebridge UI. Out of curiosity: why exactly do you do that? 🤔

On that subject: this plugin is "homebridge verified", but per https://github.com/homebridge/verified#requirements, that means:

The plugin must run on all supported LTS versions of Node.js, at the time of writing this is Node.js v16 and v18.

AFAICT that means that anything other than "node": "^16 || ^18" is in violation of that requirement? 😅

@ebaauw
Copy link
Owner

ebaauw commented Jul 6, 2023

I develop and test my plugins against the latest LTS version of NodeJS. Other versions might work, or not. I simply don't have the bandwidth to test these.

Usually a NodeJS release includes security updates, so I would recommend to update NodeJS to the latest version.

ebaauw added a commit that referenced this issue Jul 7, 2023
Bug fix: TypeError when telegram structure changes (e.g. when removing a meter), see #78.
@wimleers
Copy link
Contributor Author

Updated to 1.3.10 by now 👍

Thanks for https://github.com/ebaauw/homebridge-p1/releases/tag/v1.3.10! 🤩

I think this issue can be closed? 😊 Unfortunately I won't be able to re-test this, because I don't have a single meter left 😇

@ebaauw ebaauw closed this as completed Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants