toto / homebridge-airrohr

HomeBridge module for the DIY luftdaten.info particulates sensor. See http://luftdaten.info how to build your own
http://luftdaten.info
MIT License
52 stars 12 forks source link

Error when reading public API #2

Closed soerenjalas closed 6 years ago

soerenjalas commented 6 years ago

Hi, First of all thanks for the great plug-in! I'm trying to use the plugin via the public API, but homebridge keeps failing with the following error

 [AirRohr] Could not get sensor data: TypeError: this.dataCache.sensordatavalues is not iterable
{
    "accessory": "airrohr",
    "name": "AirRohr",
    "json_data": "http://api.luftdaten.info/v1/sensor/4668/",
    "sensor_id": "4668",
    "update_interval_seconds": 60
}

I checked the response of the API and it seems to be fine

[{"sampling_rate":null,"sensordatavalues":[{"value_type":"P1","value":"36.50","id":1404263069},{"value_type":"P2","value":"11.77","id":1404263070}],"timestamp":"2018-01-04 20:26:13","id":644020044,"sensor":{"sensor_type":{"id":14,"manufacturer":"Nova Fitness","name":"SDS011"},"pin":"1","id":4668},"location":{"longitude":"10.044","latitude":"53.568","id":2348,"country":"DE"}},{"sampling_rate":null,"sensordatavalues":[{"value_type":"P1","value":"33.57","id":1404275471},{"value_type":"P2","value":"10.70","id":1404275472}],"timestamp":"2018-01-04 20:28:40","id":644025931,"sensor":{"sensor_type":{"id":14,"manufacturer":"Nova Fitness","name":"SDS011"},"pin":"1","id":4668},"location":{"longitude":"10.044","latitude":"53.568","id":2348,"country":"DE"}}]

Do you have an idea what could be the problem?

honkmaster commented 6 years ago

Thanks for this component. A fix is very welcome!

gerritfries commented 6 years ago

Same for me. A fix would be great!

toto commented 6 years ago

This will indeed be fixed.

honkmaster commented 6 years ago

Another sample URL: http://api.luftdaten.info/v1/sensor/3139/

toto commented 6 years ago

v1.1 (just published on npm) should fix this. Note the updated config for public API vs internal network.

honkmaster commented 6 years ago

I think it needs to be reopened....

TypeError: this.dataCache.updateFromAPI is not a function

toto commented 6 years ago

Oh damn. This project needs need better tests I guess…

toto commented 6 years ago

Fixed in 1.1.3