lucacri / homebridge-http-temperature-humidity

Apache License 2.0
59 stars 36 forks source link

Temperature sensor without humidity #15

Closed matej-cupka closed 8 years ago

matej-cupka commented 8 years ago

Also I'd like to add some temperature sensor that don't have (and doesn't need) humidity sensors. I think that Homebridge could recognize that it doesn't have humidity sensor if server output is not:

{"temperature": 24,"humidity": 40}

but just:

{"temperature": 24}

Adding "humidity": false did not help

metbosch commented 8 years ago

Hi, Some time ago I had the same need, so I developed two simplified versions using this repo as a base. You can find them searching for homebridge-http-temperature and homebridge-http-humidity. The readme of each repo needs to be updated, but You can find an example of how to configure the accessory in the sample-config.json files.

matej-cupka commented 8 years ago

Hi, Thanks, just what I needed.

matej-cupka commented 8 years ago

I got this error when I tried to use your plugin after installing

/usr/local/lib/node_modules/homebridge/lib/api.js:60
      throw new Error("The requested accessory '" + name + "' was not registered by any plugin.");
      ^

Error: The requested accessory 'HttpTemperatureSensor' was not registered by any plugin.
    at API.accessory (/usr/local/lib/node_modules/homebridge/lib/api.js:60:13)
    at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:233:42)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:72:38)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)

My accessory in config.json looks like this:

{
    "accessory":        "HttpTemperatureSensor",
    "name":             "Outside Temperature Sensor",
    "url":              "http://127.0.0.1/temperature.php?id=2",
    "http_method":      "GET"
}
metbosch commented 8 years ago

Try HttpTemperature instead of HttpTemperatureSensor. The sample-config.json is wrong. Thanks for reporting the error.

matej-cupka commented 8 years ago

Now it works Thanks