RESTful Sensor with direct tcp call - not HTTP - to Claymore Miner

I am trying to get values from my Crypto Mining Rig in my garage. Its running a software called Claymore Dual Miner which supports remote calls to its api to grab data about its current state. This is useful as it has information about temperature, hash rates etc. To make such a call you can make the following json direct tcp call to the rig:

'{"id":0,"jsonrpc":"2.0","method":"miner_getstat1","psw":"letmein"}' | netcat 192.168.1.10 3333

the response is json formatted like so:

{"id": 0, "result": ["11.7 - ETH", "775", "104099;1160;0", "26567;15576;15559;19804;26591", "520497;139;0", "132839;77880;77798;99023;132957", "71;53;74;58;67;55;74;44;73;54", "eu1.ethermine.org:4444;sia-eu1.nanopool.org:7777", "0;0;0;0"], "error": null}}

I’d like to parse the returned json values into specific attributes within a sensor which the RESTful sensor is designed to do. However the RESTful sensor only seems to work with a HTTP call in the resource: field. To make the call to the Claymore Miner api it has to done using a direct tcp call (hence using netcat in my example). Does anyone know of a workaround. At the moment I’m using the Command Line sensor which calls the api and returns the json fine but I can’t seem to parse the returned json into separate attributes hence I would have to make a separate Command Line sensor for each value in the json I want to use in Home Assistant.

I had thought about running a webserver on the mining rig which runs a script using php or something similar to serve up the json to the RESTful sensor but that seems somewhat inelegant compared to calling the api direct from a sensor in Home Assistant.

Any help much appreciated.

1 Like

You might try not setting the value_template for the command line sensor, which would then store the whole json response as the state of the sensor.

You could then use a number of template sensors to extract the separate values from the state of the command line sensor.

That’s an idea - I’ll take a look - would love to use the RESTful in some though. Thanks though.

Did you ever get this working?

Probably not the best forum, but was wondering if anyone had any good mining platforms they could recommend? I have a couple of high power gaming rig’s i currently have connected to cudo miner, but was wondering if anyone had any better platforms? Thanks