Posts: 11
Threads: 1
Joined: May 2017
I did read through the summary part but was using it incorrectly, I was using it as forecast.summary() to no avail, that explains why. I tried your code and still get error ascii codec cant decode byte 0xff in position 0: ordinal not in range(128)
Is this to do with using python 3.4 vs 2.7?
Posts: 8,169
Threads: 160
Joined: Sep 2016
May-16-2017, 08:38 PM
(This post was last modified: May-16-2017, 08:38 PM by buran.)
which version do you use? python3 should not have problem with unicode chars, so btter use python3, else you need to decode it (supply codec info)
by the way, I don't see what this char could be, given the summary string...
Posts: 8,169
Threads: 160
Joined: Sep 2016
Could you post the full Traceback? At the moment for your location forecast.currently().summary is simply "Clear', so I guess it's not the problem, but some other line where you try to print temperatute with degree sign like daily().summary
import datetime
import forecastio
def main():
"""
Run load_forecast() with the given lat, lng, and time arguments.
"""
api_key = "YOUR API KEY"
lat = -31.967819
lng = 115.87718
#time = datetime.datetime(2017, 06, 05, 6, 0, 0)
forecast = forecastio.load_forecast(api_key, lat, lng) #, time=time)
#mysign = MiniSign(devicetype='sign')
print "===========Currently Data========="
current_weather = forecast.currently()
print current_weather.summary
print current_weather.temperature
print current_weather.humidity
print "===========Hourly Data========="
by_hour = forecast.hourly()
print "Hourly Summary: %s" %(by_hour.summary)
print "===========Daily Data========="
by_day = forecast.daily()
print "Daily Summary: %s" %(by_day.summary)
if __name__ == "__main__":
main() Output: ===========Currently Data=========
Clear
13.05
0.87
===========Hourly Data=========
Hourly Summary: Clear throughout the day.
===========Daily Data=========
Daily Summary: Light rain on Friday through Monday, with temperatures falling to 15°C on Saturday.
Posts: 11
Threads: 1
Joined: May 2017
May-17-2017, 01:38 PM
(This post was last modified: May-17-2017, 01:44 PM by buran.)
(May-16-2017, 08:59 PM)buran Wrote: Could you post the full Traceback? At the moment for your location forecast.currently().summary is simply "Clear', so I guess it's not the problem, but some other line where you try to print temperatute with degree sign like daily().summary
import datetime
import forecastio
def main():
"""
Run load_forecast() with the given lat, lng, and time arguments.
"""
api_key = "YOUR API KEY"
lat = -31.967819
lng = 115.87718
#time = datetime.datetime(2017, 06, 05, 6, 0, 0)
forecast = forecastio.load_forecast(api_key, lat, lng) #, time=time)
#mysign = MiniSign(devicetype='sign')
print "===========Currently Data========="
current_weather = forecast.currently()
print current_weather.summary
print current_weather.temperature
print current_weather.humidity
print "===========Hourly Data========="
by_hour = forecast.hourly()
print "Hourly Summary: %s" %(by_hour.summary)
print "===========Daily Data========="
by_day = forecast.daily()
print "Daily Summary: %s" %(by_day.summary)
if __name__ == "__main__":
main() Output: ===========Currently Data=========
Clear
13.05
0.87
===========Hourly Data=========
Hourly Summary: Clear throughout the day.
===========Daily Data=========
Daily Summary: Light rain on Friday through Monday, with temperatures falling to 15°C on Saturday.
It says I am using 3.4.2
Here is the full error code from terminal
===========Currently Data=========
Partly Cloudy
59.87
Hourly Summary: Partly cloudy throughout the day.
Error: Traceback (most recent call last):
File "mysign.py", line 36, in <module>
main()
File "mysign.py", line 33, in main
mysign.sendqueue(device='/dev/ttyUSB0')
File "/usr/local/lib/python2.7/dist-packages/pyledsign/minisign.py", line 118, in sendqueue
msgobj.data=this.processtags(msgobj.data)
File "/usr/local/lib/python2.7/dist-packages/pyledsign/minisign.py", line 273, in processtags
data=data.replace('<f:normal>',normal)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
Posts: 8,169
Threads: 160
Joined: Sep 2016
no, as you can see from the Traceback you are running it via python2.
please, post YOUR actual code
Posts: 1,298
Threads: 38
Joined: Sep 2016
Make the very first line in your script:
#! /usr/bin/env python3 or call your file using
python3 -m ./filename Linux will typically run Python v 2 by default.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Posts: 8,169
Threads: 160
Joined: Sep 2016
in addition to sparkz_alot's advice - make sure all required external packages (in your case - forecastio and pyledsign) are installed for the correct python version
Posts: 11
Threads: 1
Joined: May 2017
May-17-2017, 03:16 PM
(This post was last modified: May-17-2017, 03:20 PM by buran.)
Thank you guys so much! using sudo python3 in the command worked, I did run into the issue you talked about, Buran. I pip3 installed both applications which fixed that, I also had to add () to parts of the code to make it work in 3, which it does now! code is posted below., (which is all yours Buran, thanks very much again) I had one last question, would it be hard to implement two line text on this sign? Here is documentation on it using the same sign I have, with git info in there as well. https://medium.com/@mikemetral/a-homemad...75c73a5339
again, thank you so much for your help! I know my understanding is frustrating, just trying to learn a little bit about how this works!
#!/usr/bin/python
import datetime
import forecastio
from pyledsign.minisign import MiniSign
def main():
"""
Run load_forecast() with the given lat, lng, and time arguments.
"""
api_key = 'YOUR API KEY'
lat = 42.3314
lng = -83.0458
forecast = forecastio.load_forecast(api_key, lat, lng,)
mysign = MiniSign(devicetype='sign')
print ("===========Currently Data=========")
current_weather = forecast.currently()
print (current_weather.summary)
print (current_weather.temperature)
mysign.queuemsg(data=current_weather.summary)
mysign.sendqueue(device='/dev/ttyUSB0')
print ("===========Daily Data=========")
by_day = forecast.daily()
print ("Daily Summary: %s" %(by_day.summary))
mysign.queuemsg(data=by_day.summary)
mysign.sendqueue(device='/dev/ttyUSB0')
if __name__ == "__main__":
main()
Posts: 8,169
Threads: 160
Joined: Sep 2016
May-17-2017, 03:53 PM
(This post was last modified: May-17-2017, 03:53 PM by buran.)
you are using different package for the sign - pyledsign and he is using his own (I think) wrapper around Rubi code.
by the way in PyPi there is yet another package - https://pypi.python.org/pypi/pyLEDSign/2.0.2. I assume you installed yours from the git repo, right?
I don't see any example in your package doc that explicitly show two-line msg. I would try to send a msg with new line, i.e. '\n' in it just to see if it will yield two lines.
Posts: 11
Threads: 1
Joined: May 2017
(May-17-2017, 03:53 PM)buran Wrote: you are using different package for the sign - pyledsign and he is using his own (I think) wrapper around Rubi code.
by the way in PyPi there is yet another package - https://pypi.python.org/pypi/pyLEDSign/2.0.2. I assume you installed yours from the git repo, right?
I don't see any example in your package doc that explicitly show two-line msg. I would try to send a msg with new line, i.e. '\n' in it just to see if it will yield two lines.
I did install that package! thanks. That code for pyledsign and his own is in ruby, but that isn't the link I was refering to, I think the link maybe isn't posted in the document, my apologies. here is what I am refering to, the code was all ported from ruby to python.
https://github.com/metral/led_sign
https://github.com/metral/led_sign/blob/master/test.py
I have run the test.py (second link) on my sign and it does run fine with two lines, but I was wondering if I could implement that code with the weather you have helped me with, or is that not possible.
Thanks!
|