HackerShackOfficial / Smart-Mirror

Raspberry powered mirror which can display news, weather, calendar events
MIT License
908 stars 384 forks source link

weather #31

Closed Rimap47 closed 7 years ago

Rimap47 commented 7 years ago

Can you please let me know why I get these error ? And on the display only date/time and news comes up, nothing more. Traceback (most recent call last): File "smartmirror.py", line 158, in get_weather weather_obj = json.loads(r.text) File "/usr/lib/python2.7/json/init.py", line 338, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded Error: No JSON object could be decoded. Cannot get weather. Show less

atainter commented 7 years ago

You've added your API token, correct?

Rimap47 commented 7 years ago

thanks for your replay, I figured it out yesterday. So now its works just fine. But where does it get the news from ? I would like to see local news you know.

BaiqingL commented 7 years ago

You get news from a google rss feed using feedparser. To get your local news, find any rss feed and replace the google one. Also, you might want to remove the variables for country and only have feedparser read one rss.

Rimap47 commented 7 years ago

Thanks for your replay VBQL, I have replaced the rss feeds but gets following error:

Traceback (most recent call last): File "smartmirror.py", line 231, in get_headlines headlines_url = "www.nrk.no/nyheter/toppsaker.rss" % news_country_code TypeError: not all arguments converted during string formatting Error: not all arguments converted during string formatting. Cannot get news.

Which variables should I remove ?

BaiqingL commented 7 years ago

You should remove the news variables that contains the country codes, that seems to mess it up for me.

BaiqingL commented 7 years ago

Or just replace the News class with the following

class News(Frame): def __init__(self, parent, *args, **kwargs): Frame.__init__(self, parent, *args, **kwargs) self.config(bg='black') self.title = 'News' self.newsLbl = Label(self, text=self.title, font=('Helvetica', medium_text_size), fg="white", bg="black") self.newsLbl.pack(side=TOP, anchor=W) self.headlinesContainer = Frame(self, bg="black") self.headlinesContainer.pack(side=TOP) self.get_headlines() def get_headlines(self): try: for widget in self.headlinesContainer.winfo_children(): widget.destroy() feed = feedparser.parse("www.nrk.no/nyheter/toppsaker.rss") for post in feed.entries[0:5]: headline = NewsHeadline(self.headlinesContainer, post.title) headline.pack(side=TOP, anchor=W)

Rimap47 commented 7 years ago

Thank you VBQL, looks like that did the jobb. Can I ask you for 1 more thing ?

Regarding the location.

When i set the latitude and longitude, the code doesnt display the location and shows the weather degree unormal-ly high. And doesnt give any error either.

If i remove the latitude and longitude strings, then the code shows " can not pin point location" and weather degree become normal.

latitude = '60.408639' # Set this if IP location lookup does not work for you (must be a string) longitude = '5.227588' # Set this if IP location lookup does not work for you (must be a string)

I also tried it without apostrophe (')

BaiqingL commented 7 years ago

First, you might want geolocation to be obtained from google maps, also, the default location weather is displayed in Fahrenheit. To change in celsuis, change the code from: return 1.8 * (kelvin_temp - 273) + 32 to return kelvin_temp - 273

delahoya1 commented 7 years ago

riman47 how did you figure out the error?

pallense commented 7 years ago

I downloaded the software ( package) and install them from the folder

On Wed, Nov 30, 2016, 7:25 PM delahoya1 notifications@github.com wrote:

riman47 how did you figure out the error?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HackerHouseYT/Smart-Mirror/issues/31#issuecomment-264068937, or mute the thread https://github.com/notifications/unsubscribe-auth/AF7cNNULRu_YRDPbIwV6ioZraaiTXoHWks5rDj4vgaJpZM4KtZ6Q .

liquid1 commented 7 years ago

rimap47?? how did you figure out the error?

Rimap47 commented 7 years ago

Which issue ?

rosegoldthakur commented 7 years ago

@Rimap47 how did you fix the Weather issue ? explain please.

Rimap47 commented 7 years ago

"add api token" did fix the issue.

ShraddhaDevaiya commented 7 years ago

@Rimap47 I added api token still it showing this type of error

Sent from my Xiaomi Redmi 3S using FastHub