Freeboard / freeboard

A damn-sexy, open source real-time dashboard builder for IOT and other web mashups. A free open-source alternative to Geckoboard.
http://freeboard.io
MIT License
6.44k stars 1.2k forks source link

Thingspeak JSON Datasource NaN #243

Closed KeepSummerSaf3 closed 6 years ago

KeepSummerSaf3 commented 6 years ago

I am having some trouble displaying valid JSON data in a sparkline or gauge widget. The datasources are updating correctly. Please reference my dashboard JSON config file. I am certain my datasource is not referenced correctly within the respective widgets.

Dashboard.JSON {"version":1,"allow_edit":true,"plugins":[],"panes":[{"width":1,"row":{"3":1},"col":{"3":1},"col_width":1,"widgets":[{"type":"sparkline","settings":{"title":"Indoor Humidity","value":["datasources[\"Thingspeak Humidity\"][\"channel\"][\"field2\"]"]}},{"type":"sparkline","settings":{"title":"Indoor Temperature","value":["datasources[\"Thingspeak Indoor Temperature\"][\"channel\"][\"field1\"]"],"include_legend":false}},{"type":"ragIndicator","settings":{"title":"","value":"datasources[\"Thingspeak AC Status\"][\"channel\"][\"field3\"]","green_text":"AC ON","red_text":"AC OFF","indicator_type":"NORMAL"}},{"type":"ragIndicator","settings":{"value":"datasources[\"Thingspeak HEAT Status\"][\"channel\"][\"field4\"]","green_text":"HEAT ON","red_text":"HEAT OFF","indicator_type":"NORMAL"}},{"type":"ragIndicator","settings":{"value":"datasources[\"Thingspeak FAN Status\"][\"channel\"][\"field5\"]","green_text":"FAN ON","red_text":"FAN OFF","indicator_type":"NORMAL"}}]},{"width":1,"row":{"3":17},"col":{"3":1},"col_width":1,"widgets":[{"type":"sparkline","settings":{"title":"Thingspeak Free Memory","value":["datasources[\"Thngspeak Free Memory\"][\"channel\"][\"field6\"]"]}}]},{"width":1,"row":{"3":15},"col":{"3":3},"col_width":1,"widgets":[{"type":"sparkline","settings":{"title":"WeatherData_Temperature","value":["datasources[\"HoustonWeatherData\"][\"temperature\"]"]}}]},{"title":"Google Map","width":1,"row":{"3":5},"col":{"3":2},"col_width":2,"widgets":[{"type":"google_map","settings":{"lat":"29.9735096","lon":"-95.58548280000002"}}]},{"width":1,"row":{"3":1},"col":{"3":2},"col_width":2,"widgets":[{"type":"text_widget","settings":{"title":"System Clock","size":"regular","value":"datasources[\"System Clock\"][\"full_string_value\"]","animate":true}}]}],"datasources":[{"name":"HoustonWeatherData","type":"openweathermap","settings":{"api_key":"066d502693de8dbdb6065a22d0143a78","location":"Houston, TX","units":"imperial","refresh":3600}},{"name":"Thingspeak Indoor Temperature","type":"JSON","settings":{"url":"https://thingspeak.com/channels/6823/field/1.json","use_thingproxy":true,"refresh":60,"method":"GET","name":"Thingspeak Indoor Temperature"}},{"name":"Thngspeak Free Memory","type":"JSON","settings":{"url":"https://thingspeak.com/channels/6823/field/6.json","use_thingproxy":true,"refresh":60,"method":"GET"}},{"name":"Thingspeak Humidity","type":"JSON","settings":{"url":"https://thingspeak.com/channels/6823/field/2.json","use_thingproxy":true,"refresh":60,"method":"GET"}},{"name":"Thingspeak AC Status","type":"JSON","settings":{"url":"https://thingspeak.com/channels/6823/field/3.json","use_thingproxy":true,"refresh":60,"method":"GET"}},{"name":"Thingspeak HEAT Status","type":"JSON","settings":{"url":"https://thingspeak.com/channels/6823/field/4.json","use_thingproxy":true,"refresh":60,"method":"GET"}},{"name":"Thingspeak FAN Status","type":"JSON","settings":{"url":"https://thingspeak.com/channels/6823/field/5.json","use_thingproxy":true,"refresh":60,"method":"GET"}},{"name":"System Clock","type":"clock","settings":{"refresh":1}}],"columns":3}

capture2

bugvish commented 6 years ago

@airsoftsoldrecn9: The data fields you have chosen to associate with your widgets are sending simply label strings, not the actual numerical values themselves. I have migrated your freeboard JSON to freeboard.io, and changed your widgets to Text in order to illustrate your issue: https://freeboard.io/board/Qrwbw8. For example, your top left widget is associated with datasources["Thingspeak Humidity"]["channel"]["field2"]; the value coming from Thingspeak for this field is the string literal "Indoor Humidity", NOT any actual numerical value. You have this issue across most of your widgets. If you wish to use numerical widgets like Sparkline and Gauge, please be sure you are feeding them with numerical data.

KeepSummerSaf3 commented 6 years ago

In retrospect that should have been the obvious resource to track down the issue using a text widget (thank you for noting it), as the JSON schema includes field name, timestamps, etc. for the specified number of entries. Either I could parse: https://api.thingspeak.com/channels/<channel#>/fields/<field#>.json

OR simply use: https://api.thingspeak.com/channels/<channel#>/feeds/last.json