xfjx / homebridge-wunderground

Weather Underground plugin for Homebridge: https://github.com/nfarina/homebridge
29 stars 10 forks source link

How do I find the correct format for my city? #2

Closed brianhanifin closed 7 years ago

brianhanifin commented 8 years ago

I live in Santee, California, in the United States.

xfjx commented 8 years ago

Hey,

This should be CA/Santee for city.

Please let me know if it works.

xfjx commented 8 years ago

Just checked it. CA/Santee will query this in wunderground:

Santee, CA Santee CA California US US 92071 1 99999 32.84790802 -116.98807526 104.00000000
brianhanifin commented 8 years ago

Thank you. Where can you query that information? I can't seem to find it on the WUnderground site.

Here is what I have in my accessory config.

{
    "accessory": "WUNDERGROUND",
    "name": "Weather Underground",
    "device": "KCASANTE33",
    "key": "[my developer key]",
    "city": "CA/Santee"
}

As soon as Apple's iOS 10 Home app tries to query the weather data, homebridge crashes with the following messages.

[9/19/2016, 5:56:43 PM] [Weather Underground] Successfully fetched weather data from wunderground.com
/usr/local/lib/node_modules/homebridge-wunderground/index.js:36
            that.temperature = response['current_observation']['temp_c'];
                                                              ^

TypeError: Cannot read property 'temp_c' of undefined
    at null.<anonymous> (/usr/local/lib/node_modules/homebridge-wunderground/index.js:36:57)
    at Request._callback (/usr/local/lib/node_modules/homebridge-wunderground/node_modules/wundergroundnode/lib/wundergroundnode.js:137:26)
    at Request.self.callback (/usr/local/lib/node_modules/homebridge-wunderground/node_modules/wundergroundnode/node_modules/request/request.js:187:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/homebridge-wunderground/node_modules/wundergroundnode/node_modules/request/request.js:1048:10)
    at emitOne (events.js:77:13)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/homebridge-wunderground/node_modules/wundergroundnode/node_modules/request/request.js:969:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:921:12)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)

Is this error occurring because my locale uses Fahrenheit instead of Celsius?

xfjx commented 8 years ago

You can use this URL to fetch the information with your browser:

http://api.wunderground.com/api/*your_key_here*/conditions/lang:DL/q/CA/Santee.xml

There is always an temp_c and temp_f. Maybe your key is not correct?

evitiello commented 7 years ago

Based on the wunderground API docs (https://www.wunderground.com/weather/api/d/docs?d=data/index) it looks like you can use a bunch of different formats:

The location for which you want weather information. Examples: CA/San_Francisco US state/city 60290 US zipcode Australia/Sydney country/city 37.8,-122.4 latitude,longitude KJFK airport code pws:KCASANFR70 PWS id autoip AutoIP address location autoip.json?geo_ip=38.102.136.138