Comments (8)
Yes you can just skip using the homebridge part of this code and use the Scanner
.
const { Scanner } = require("homebridge-mi-hygrothermograph/lib/scanner");
const scanner = new Scanner();
scanner.on("temperatureChange", function (value, peripheral) {
console.log("Temperature", value);
});
scanner.on("humidityChange", function (value, peripheral) {
console.log("Humidity", value);
});
scanner.on("batteryChange", function (value, peripheral) {
console.log("Battery", value);
});
Good luck!
from homebridge-mi-hygrothermograph.
Your example was great for 1 device, but right now i have a total of 4 sensors and it got pretty unstable.
This is is how the server looks right now and sometimes it's crashing and it was not hapening with 1 device.
I want to ask for a suggestionof a better way of reading from multiple devices.
Thanks!
const io = require('socket.io')();
const { Scanner } = require("homebridge-mi-hygrothermograph/lib/scanner");
const scanner = new Scanner();
io.set("origins", "*:*");
const bedroomId = '4c65a8daa726'
const kitchenId = '4c65a8dd7c37'
const vladId = '4c65a8dae1b7'
const livingId = '4c65a8dd7fc9'
io.on('connection', (client) => {
scanner.on("temperatureChange", function (temperature, peripheral) {
if (peripheral.id === bedroomId) {
client.emit('temperatureBedroom', temperature)
} else if (peripheral.id === kitchenId) {
client.emit('temperatureKitchen', temperature)
} else if (peripheral.id === vladId) {
client.emit('temperatureVlad', temperature)
} else if (peripheral.id === livingId) {
client.emit('temperatureLiving', temperature)
}
});
scanner.on("humidityChange", function (humidity, peripheral) {
if (peripheral.id === bedroomId) {
client.emit('humidityBedroom', humidity)
} else if (peripheral.id === kitchenId) {
client.emit('humidityKitchen', humidity)
} else if (peripheral.id === vladId) {
client.emit('humidityVlad', humidity)
} else if (peripheral.id === livingId) {
client.emit('humidityLiving', humidity)
}
});
});
const port = 4001;
io.listen(port);
from homebridge-mi-hygrothermograph.
Really hard to help you without you providing more information than that it's unstable and crashing. But one thing you could try is to have one Scanner
per sensor i.e new Scanner(bedroomId)
etc.
from homebridge-mi-hygrothermograph.
This is the error before crashing, probbaly won't help with anything:
uncaughtException: Unknown event type: 1037. 5020aa0149377cdda8654c0d040020015202
Error: Unknown event type: 1037. 5020aa0149377cdda8654c0d040020015202
at Parser.parseEventData
I will try your example.
from homebridge-mi-hygrothermograph.
This error is actually a known issue: #56
Did you upgrade your system or anything like that around the time you started seeing these errors?
Also you could listen for the error-event to not crash the node-process on errors emitted by the scanner:
scanner.on("error", error => console.log(error));
from homebridge-mi-hygrothermograph.
I did completely reinstalled my RPi3 recently.
I am getting similar error to #56 . At first i thought it's because i use multiple sensors, but just tested and it's crashing even with 1 sensor.
Error: Unknown event type: 525. 5020aa018cc97fdda8654c0d0200ae043e26
at Parser.parseEventData (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:174:15)
at Parser.parse (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/parser.js:56:23)
at Scanner.parseServiceData (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:161:38)
at Scanner.onDiscover (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25)
at Noble.emit (events.js:198:13)
at Noble.onDiscover (/home/pi/soft/home-automation-api/node_modules/@abandonware/noble/lib/noble.js:178:10)
at NobleBindings.emit (events.js:198:13)
at NobleBindings.onDiscover (/home/pi/soft/home-automation-api/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:174:10)
at Gap.emit (events.js:198:13)
at Gap.onHciLeAdvertisingReport (/home/pi/soft/home-automation-api/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10)
Emitted 'error' event at:
at Scanner.parseServiceData (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:163:12)
at Scanner.onDiscover (/home/pi/soft/home-automation-api/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js:90:25)
[... lines matching original stack trace ...]
at Gap.onHciLeAdvertisingReport (/home/pi/soft/home-automation-api/node_modules/@abandonware/noble/lib/hci-socket/gap.js:256:10)
at Hci.emit (events.js:198:13)
at Hci.processLeAdvertisingReport (/home/pi/soft/home-automation-api/node_modules/@abandonware/noble/lib/hci-socket/hci.js:651:10)
The on error event doesn't help. It works for a while ..like minutes ..and then i'm seeing the error message and the app crashes.
bedroomScanner.on("error", error => console.log(error));
from homebridge-mi-hygrothermograph.
Hmmm decided to give this another try, and now in version 2.3.2 it's not crashing anymore ...at least not yet! :D
Keep up the good work!
from homebridge-mi-hygrothermograph.
I was wrong. It's still throwing the same error.
I posted a new issue #85
from homebridge-mi-hygrothermograph.
Related Issues (20)
- 'Current Temperature': characteristic was supplied illegal value: number -21.1 exceeded minimum of -10 HOT 1
- how to install mi-hygrothermograph on the terminal HOT 1
- Homebridge restarting ENODEV error HOT 3
- Error: Error: Unsupported state or unable to authenticate data HOT 2
- ERROR INITIALIZING PLUGIN homebridge-mi-hygrothermograph HOT 2
- error installing plugin
- Fertility, Light, Moisture not shown in Apple Home Kit HOT 3
- Mac adress HOT 1
- shutting down Homebridge ?,Hygrothermograph 2 / LYWSD03MMC HOT 5
- Missing dependency 404 (nonexistent) HOT 18
- Plugin can't read data from LYWSD02MMC
- Plugin won't load after homebridge and node update HOT 3
- issues with cap_net_raw priviliges HOT 2
- No data from LYWSD03MMC HOT 5
- Error log
- Not working after updated to NodeJS 20.x version HOT 7
- LYWSDCGQ01ZM not showing in EVE rooms HOT 6
- Offset-Humidity in Advanced Configuration not working correctly
- Not receiving decimal/float temperature values in influxDB/Grafana
- LYWSDCGQ01ZM error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homebridge-mi-hygrothermograph.