cyrils / renogy-bt

Python library to read Renogy compatible BT-1 or BT-2 bluetooth modules using Raspberry Pi.
GNU General Public License v3.0
76 stars 27 forks source link

dump example.py to text file or json locally? #51

Closed bserret closed 6 months ago

bserret commented 6 months ago

I would like to just dump the output to a text file, or a local json file but I see no way to do that - a redirect "python example.py >>output.txt" does not work. The php post seems to work (code 200) but I am not skilled enough with php to have it dump to a file - how does it even execute on the server side? I presume $json_data is getting populated but a file_put_contents doesn't do anything. Likely my misunderstanding of how php works regarding dumping output to a local file on the server...

Thanks for any suggestions.

cyrils commented 6 months ago

Turn off all logging in your config.ini and write your code after example.py#L18.

with open('dump.txt', 'w') as f:
    f.write(json.dumps(filtered_data))
bserret commented 6 months ago

I had to add import json but otherwise that worked perfectly thanks!