Comments (12)
OK, complete dirty hack but works for me and seems to stop crashing:
In
homebridge-http-temperature\node_modules\sync-request\index.js
change line 31 from:
throw new Error(response.error.message || response.error || response);
to
return;
In
homebridge-http-temperature\index.js
change this bit around line 42:
if(res.statusCode > 400){
this.log('HTTP get state function failed');
callback(error);
to
if(res == null){
this.log('HTTP get state function failed');
callback(null, 0);
It then just reports 0 temperature instead of Error = Crash.
It wont log a proper error but in my testing that doesn't really matter, id prefer a temp of 0 then the bridge crashing.
EDIT: I found that if the temp sensor was giving a reading of 'nan' homebridge would also crash.
Think I've sussed with this mod in the getstate method:
getState: function (callback) {
var body;
var res = request(this.http_method, this.url, {});
if(res == null){
this.log('HTTP get state function failed');
callback(null, 0);
} else {
this.log('HTTP get state function succeeded!');
if (res.body.toString().indexOf("nan") > -1)
{
this.log('Ignoring value: nan');
callback(null, 0);
}
else
{
var info = JSON.parse(res.body);
this.temperatureService.setCharacteristic(
Characteristic.CurrentTemperature,
info.temperature
);
this.log(info);
this.temperature = info.temperature;
callback(null, this.temperature);
}
}
},
from homebridge-http-temperature-humidity.
Sorry, really no idea. Anyone else experiencing the same problem?
from homebridge-http-temperature-humidity.
I get same problem on a timeout. Anything we could do to stop a fatal crash at line 31 of sync-requests/index.js? I tried to have a play around but didn't get anywhere. If it could just log error but not crash completely..
\npm\node_modules\homebridge-http-temperature\node_modules\sync-request\index.js:31
throw new Error(response.error.message || response.error || response);
^
Error: connect ETIMEDOUT 192.168.1.123:80
at doRequest (C:\Users\paul.obrien\AppData\Roaming\npm\node_modules\homebridge-http-temperature\node_modules\sync-request\index.js:31:11)
at Object.HttpTemperature.getState (C:\Users\paul.obrien\AppData\Roaming\npm\node_modules\homebridge-http-temperature\index.js:41:17)
at emitThree (events.js:97:13)
at emit (events.js:175:7)
at Characteristic.getValue (C:\Users\paul.obrien\AppData\Roaming\npm\node_modules\homebridge\node_modules\hap-nodejs\lib\Characteristic.js:120:10)
at Bridge. (C:\Users\paul.obrien\AppData\Roaming\npm\node_modules\homebridge\node_modules\hap-nodejs\lib\Accessory.js:621:20)
at Array.forEach (native)
at Bridge.Accessory._handleGetCharacteristics (C:\Users\paul.obrien\AppData\Roaming\npm\node_modules\homebridge\node_modules\hap-nodejs\lib\Accessory.js:585:8)
at emitMany (events.js:108:13)
at HAPServer.emit (events.js:182:7)
from homebridge-http-temperature-humidity.
We should see if the HomeKit standard allows a return type of "unavailable " and return that in case of exceptions
On Nov 6, 2016, 6:58 AM -0500, paulobriennz [email protected], wrote:
I get same problem on a timeout. Anything we could do to stop a fatal crash at line 31 of sync-requests/index.js? I tried to have a play around but didn't get anywhere. If it could just log error but not crash completely..
\npm\node_modules\homebridge-http-temperature\node_modules\sync-request\index.js:31
throw new Error(response.error.message || response.error || response);
^Error: connect ETIMEDOUT 192.168.1.123:80
at doRequest (C:\Users\paul.obrien\AppData\Roaming\npm\node_modules\homebridge-http-temperature\node_modules\sync-request\index.js:31:11)
at Object.HttpTemperature.getState (C:\Users\paul.obrien\AppData\Roaming\npm\node_modules\homebridge-http-temperature\index.js:41:17)
at emitThree (events.js:97:13)
at emit (events.js:175:7)
at Characteristic.getValue (C:\Users\paul.obrien\AppData\Roaming\npm\node_modules\homebridge\node_modules\hap-nodejs\lib\Characteristic.js:120:10)
at Bridge. (C:\Users\paul.obrien\AppData\Roaming\npm\node_modules\homebridge\node_modules\hap-nodejs\lib\Accessory.js:621:20)
at Array.forEach (native)
at Bridge.Accessory._handleGetCharacteristics (C:\Users\paul.obrien\AppData\Roaming\npm\node_modules\homebridge\node_modules\hap-nodejs\lib\Accessory.js:585:8)
at emitMany (events.js:108:13)
at HAPServer.emit (events.js:182:7)—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub (#19 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/ACx0-4Vl2SGkGQJLJtTG3XfHkOCIJbMyks5q7cD7gaJpZM4KB6xh).
from homebridge-http-temperature-humidity.
I get same problem .....
from homebridge-http-temperature-humidity.
could we just log error in console but not return anything so homebridge doesn't know any different and we don't throw a (fatal) error? I tried messing around with the return to try and get as close to 'null' as I could but just don't have enough experience to know what I am really doing..
in this part of
homebridge-http-temperature\node_modules\sync-request\index.js
where it returns successful HttpResponse or throws the error (which crashes homebridge), can we somehow modify the throw new Error line to throw a non threatening HttpResponse of nothing? I tried returning a fake 'nothing' HttpResponse but got tripped up on not passing back headers etc.
I don't quite get how in other plugins, you just get a log of connection refused etc., timeout but in this plugin it throws a fatal error. is it because of this sync-request dependency? is there another way to do an httrRequest that doesn't crash homebridge on error? or is the problem back in the http-temperature\index.js where the returned error get's handled?
if (response.success) {
return new HttpResponse(response.response.statusCode, response.response.headers, response.response.body, response.response.url);
} else {
throw new Error(response.error.message || response.error || response);
from homebridge-http-temperature-humidity.
Do you want to submit a PR?
from homebridge-http-temperature-humidity.
i guess i have fixed the issue
try it and tell me what you think:
sudo npm install -g https://github.com/PeterBrain/homebridge-http-temperature-humidity
from homebridge-http-temperature-humidity.
I had the same issue if the ip address is not reachable. For example my thermometer is disconnected or unplugged. Is this solved in last version?
Have you pushed the fix to production version?
from homebridge-http-temperature-humidity.
@lucacri is the issue fixed with merge of pull request #29 ?
from homebridge-http-temperature-humidity.
I didn't try it (not using this module at the time), can anyone check version 0.0.16 and report back?
from homebridge-http-temperature-humidity.
The version from npm is not working correctly and is not containing last code from here. So actually I switched to https://www.npmjs.com/package/homebridge-advanced-http-temperature-humidity which is working also with disconnected thermometer or unreachable url endpoint.
from homebridge-http-temperature-humidity.
Related Issues (20)
- Too frequent http requests HOT 1
- Not working with negative value HOT 1
- Add air pressure? HOT 4
- Still "no reply" with negative temperature HOT 6
- Faking the http results HOT 1
- Two accessories in config.json? HOT 1
- version bump HOT 1
- max humidity 200 HOT 1
- Request: FakeGato Integration
- Difference between Home Humidity reported in Home app HOT 4
- Seems this is no longer available on npmjs.org HOT 2
- 0 degrees all the time HOT 1
- HTTP Failure HOT 5
- get temp an humidity fron esp easy with bme280
- Humidity calculates to zero
- Won't update my temperature, never go below 0 celsius HOT 1
- can't remove decimal
- MicroPython ESP8266 Endpoint
- Decimal places
- DOESNT WORK AT ALL HOT 4
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-http-temperature-humidity.