OneWire Probe Query

Just got my BrewPi and love it. Already have it set up monitoring water temperature as a test.

My question is how can I, with a python script, pull the current values of my four OneWire probes?
I’m using as a guide but I don’t want a continuous script running. I want the script to execute, query and output the values per my request.

$ python
$ {“OneWire#1”: 74.3, “OneWire#2”: 56.3, … }

Any thoughts?

A few additional notes:
I have a RaspberryPi and the BrewPi software is running. I’d like the script to stay on the RaspberryPi and just forward the results to my logging server but I can handle that. I also tried running the straight from the command line and I can output some of the values properly as long as the BrewPi scripts aren’t on. Is there a way around that issue?

Until we have a better api in place, this could maybe be a quick hack approach:
If you send ‘h{v:1}\n’ to the serial port, it will return all discovered and installed devices with values.

You could identify the sensors by OneWire address.

You can get the same info by sending doing two post messages to socketmessage.php:

$.post('socketmessage.php', {messageType: "refreshDeviceList", message: "readValues");
$.post('socketmessage.php', {messageType: "getDeviceList", message: "");

Thanks for the help, that certainly put me on the right track:

import serial

brewpi = serial.Serial('/dev/ttyACM0', 57600, timeout=1)




$ python3
[b'h:[{"i":0,"t":1,"c":1,"b":0,"f":6,"h":2,"d":0,"p":0,"v":  76.887,"a":"28088EFE08000097","j":  0.000},{"i":2,"t":1,"c":1,"b":1,"f":9,"h":2,"d":0,"p":0,"v":            78.461,"a":"284717C207000087","j":  0.000},{"i":1,"t":1,"c":1,"b":0,"f":5,"h":2,"d":0,"p":0,"v":  74.414,"a":"28E7B6C1070000AD","j":  0.000},{"i":-1,"t":1,          "c":1,"b":0,"f":5,"h":2,"d":0,"p":0,"v":  78.574,"a":"28DF56C2070000B3","j":  0.000},{"i":-1,"t":0,"c":1,"b":0,"f":0,"h":1,"d":0,"p":17,"x":0},{"i":-1,"t":0,          "c":1,"b":0,"f":0,"h":1,"d":0,"p":16,"x":0},{"i":-1,"t":0,"c":1,"b":0,"f":0,"h":1,"d":0,"p":11,"x":0},{"i":-1,"t":0,"c":1,"b":0,"f":0,"h":1,"d":0,"p":10,"x":          0}]\r\n']

Now I just need to extract that, format and send it to my logging server. Thanks for the help!