gtfierro / xboswave

eXtensible Building Operating System built on WAVE and WAVEMQ
BSD 3-Clause "New" or "Revised" License
10 stars 6 forks source link

weather_current.py doesn't work without changing message name #24

Closed akshephard closed 5 years ago

akshephard commented 5 years ago

I cloned the latest version of xboswave and tried to run the weather_current.py driver and received this error:

future: <Task finished coro=<Driver.begin.<locals>.readloop() done, defined at /home/solarplus/xboswave-1/python/pyxbos/pyxbos/driver.py:86> exception=ValueError('Protocol message XBOSIoTDeviceState has no "weather_station" field.')> Traceback (most recent call last): File "/home/solarplus/xboswave-1/python/pyxbos/pyxbos/driver.py", line 88, in readloop await _doread() File "/home/solarplus/xboswave-1/python/pyxbos/pyxbos/driver.py", line 84, in _doread self.read(requestid=requestid) File "weather_current.py", line 55, in read ozone = types.Double(value=output.get('ozone',None)), ValueError: Protocol message XBOSIoTDeviceState has no "weather_station" field.

After diff'ing this driver with my working version with the version in the latest version in your repo I found that your version has: weather_station = weather_station_pb2.WeatherStation(

https://github.com/gtfierro/xboswave/blob/7e8439d5852325ae81dd356efa26c7d52ec7492c/python/pyxbos/pyxbos/drivers/weather_current/weather_current.py#L35

This did not work on the Solarplus NUC. I changed it to:

weather_current = weather_station_pb2.WeatherStation(

https://github.com/akshephard/xboswave-1/blob/084a5d2b36de8e53dda5d7b7f89c5c208b137a95/python/pyxbos/pyxbos/drivers/weather_current/weather_current.py#L35

This worked and I'm not sure where the reference to weather_current is since all of the proto files have weather_station. Any ideas where this is coming from?

gtfierro commented 5 years ago

This is most likely due to an outdated pyxbos installation; can you run pip install --upgrade pyxbos and see if the error persists?

akshephard commented 5 years ago

The error did persist after upgrading. (base)solarplus@solarplusnuc:~/xbos_06_19/xboswave/python/pyxbos/pyxbos/drivers/weather_current$ pip show pyxbos Name: pyxbos Version: 0.2.8

gtfierro commented 5 years ago

It may be that your generated Python files are out of date. Can you try regenerating those from the proto files?

gtfierro commented 5 years ago

I would also look at what environment you are using. There's a chance that when you execute the driver from that directory, it uses the iot_pb2 file in your pyxbos folder (see here). I would recommend installing pyxbos in a virtualenv outside of the source directory python/pyxbos/

akshephard commented 5 years ago

I just did: make proto; make proto-py

That fixed it. I had already done that previously. I also did update the version of pyxbos. Thanks for the help!

gtfierro commented 5 years ago

Great! Glad its working

akshephard commented 5 years ago

Okay so after trying to run weather_prediction.py I ran into a similar issue. I printed out iot_pb2. __file__ and received this: /home/solarplus/anaconda3/lib/python3.7/site-packages/pyxbos/iot_pb2.py

We are already running a virtual environment(conda) because we needed multiple versions of python for some libraries we are using for Pymodbus. So you suggest I do my pip install in a separate virtualenv?

akshephard commented 5 years ago

I was able to fix this there was an issue with the name https://github.com/gtfierro/xboswave/blob/edabdf41549486da49f3a5595718b8921b5c14ae/python/pyxbos/pyxbos/drivers/weather_prediction/weather_prediction.py#L72

This should line should be: weather_station_prediction = weather_station_pb2.WeatherStationPrediction(

To be reflective of the new name.

gtfierro commented 5 years ago

Good find! Would you mind submitting a PR to fix this?

akshephard commented 5 years ago

Yes I will submit a PR!