koalatux / koubachi-pyserver

MIT License
15 stars 11 forks source link

Problems running. #14

Closed Peterpc58 closed 3 years ago

Peterpc58 commented 4 years ago

I have installed the server, but when I push the button on my Koubachi, I get this: 192.168.86.88 - - [14/Jul/2020 20:35:38] "PUT /v1/smart_devices/0006668015b6?locale=en HTTP/1.1" 200 - [2020-07-14 20:35:44,465] ERROR in app: Exception on /v1/smart_devices/0006668015b6/readings [POST] Traceback (most recent call last): File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functionsrule.endpoint File "/home/pi/koubachi-pyserver/src/koubachi_pyserver/app.py", line 171, in add_readings handle_readings(mac_address, convert_readings(mac_address, body_parsed)) File "/home/pi/koubachi-pyserver/src/koubachi_pyserver/app.py", line 95, in handle_readings write_to_csv(mac_address, readings, directory=output['directory']) File "/home/pi/koubachi-pyserver/src/koubachi_pyserver/app.py", line 115, in write_to_csv with open(file_path, 'x') as file: FileNotFoundError: [Errno 2] No such file or directory: '/tmp/koubachi_sensor_readings/0006668015b6_button.csv' 192.168.86.88 - - [14/Jul/2020 20:35:44] "POST /v1/smart_devices/0006668015b6/readings?locale=en HTTP/1.1" 500 - [2020-07-14 20:35:47,453] ERROR in app: Exception on /v1/smart_devices/0006668015b6/readings [POST] Traceback (most recent call last): File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "/home/pi/.local/share/virtualenvs/koubachi-pyserver-1kINM90X/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request return self.view_functionsrule.endpoint File "/home/pi/koubachi-pyserver/src/koubachi_pyserver/app.py", line 171, in add_readings handle_readings(mac_address, convert_readings(mac_address, body_parsed)) File "/home/pi/koubachi-pyserver/src/koubachi_pyserver/app.py", line 95, in handle_readings write_to_csv(mac_address, readings, directory=output['directory']) File "/home/pi/koubachi-pyserver/src/koubachi_pyserver/app.py", line 115, in write_to_csv with open(file_path, 'x') as file: FileNotFoundError: [Errno 2] No such file or directory: '/tmp/koubachi_sensor_readings/0006668015b6_button.csv' 192.168.86.88 - - [14/Jul/2020 20:35:47] "POST /v1/smart_devices/0006668015b6/readings?locale=en HTTP/1.1" 500 - What am I doing wrong?

koalatux commented 4 years ago

Hi Peter,

The directory where you want to store the CSV files to has to exist. Try executing mkdir /tmp/koubachi_sensor_readings and then start the server again.

Cheers, Adi

Peterpc58 commented 4 years ago

Hi Adi, Thanks for your help. I know how to setup the config.yml file now. I get the readings now in MQTT!

Peterpc58 commented 4 years ago

Do you know the values for soil_moisture?

Peterpc58 commented 4 years ago

Is there a way to check if the server is still running? Sometimes I get a network error and the server stops. But I don't know it has stopped. I use Homeseer to get the MQTT values. Can I send a MQTT command to see if everything is ok? Or a HTML get? Or any other way?

koalatux commented 4 years ago

Hi, I just added a new feature. The server will now reply with a http status code 200 if you perform a GET request to /. The text content may change in the future, it just says OK for now.

You now might do a simple check e.g. with curl like: curl -sSf -o /dev/null http://localhost:8005/ && echo "server is OK"

koalatux commented 4 years ago

Do you know the values for soil_moisture?

If I remember correctly, the soil_moisture is the matrix potential, but I don't know what the absolute values mean.

Peterpc58 commented 4 years ago

Hi, I just added a new feature. The server will now reply with a http status code 200 if you perform a GET request to /. The text content may change in the future, it just says OK for now.

You now might do a simple check e.g. with curl like: curl -sSf -o /dev/null http://localhost:8005/ && echo "server is OK"

Works perfect, thanks!