Kohler Oncue Generator Oil Temperature

Couldn’t find this anywhere but wanted to post in case others search for this. At our camp in Maine we’ve got a standby generator and have been having issues with the cold weather kit designed to keep the oil warm in case of an outage.

I want to track the oil temp in HA. I haven’t found an oncue integration but did stumble across this link:

So in order to grab the oil temp (turns out it is parameter 18 in Oncue) I wrote this simple python script:

from requests import get

response = get("https://api.kohler.com/krm/v1/users/connect?username=<USERNAME>&password=<Password>&dateformat=m-d%20g:i%20A")
sessionkey = response.json()["sessionkey"]
url = "https://api.kohler.com/krm/v1/devices/listdevices?sessionkey="+sessionkey+"&parameters=[18]&events=active&showperipheraldetails=true"
#print(url)
response = get(url)

print(response.json()[0]["parameters"][0]["value"])

And then call it using the command line sensor:

  - platform: command_line
    command: python "<PATH TO SCRIPT>\kohler.py"
    name: Kohler Oil Temperature
    unit_of_measurement: '°F'

I’m sure it can be easily expanded to include other attributes.

Adam

Hi Adam,
I just got on line with my Kohler gen and OnCue. Did you do any more with this?

Nothing more than the oil temp at this point. That said if you take a look at the json you get back from the generator I’m sure there’s a lot that could be done.

1 Like

Reading the link above shows you can also get whether you are on gen power vs utility power without other components. I was going to use a nodemcu with CTs. This maybe easier. Time to start playing with the script to learn what it can do.

That should definitely be doable.

Post back if you make progress. I may look into doing the same. Just spent 3 days on generator up here after the noreaster blew through.

A

I started playing with it and used your scripts as written (with user name / password for me) and I do not get oil temp. I then ran the following from chrome browser

https://api.kohler.com/krm/v1/users/connect?username=xxx&password=xxxx&dateformat=m-d%20g:i%20A

This returns a session Id
I then ran

https://api.kohler.com/krm/v1/devices/listdevices?sessionkey=xxx&parameters=[4,11,60,69,102,91,114,115,549]&events=active&showperipheraldetails=true

And this returns a lot of info but not the oil temp. I then re-read your directions and added the 18 and got the oil temp.
A couple of questions.
How did you figure out what parameters numbers correspond to what parameter in the kohler generator? I am currently trying in the browser 1-200 and this seems to capture a lot of info. If interested in what goes to what, I can share this later.

When I run the script as written I get the kohler oil temperature as unknown in the developer tools. I must be doing something wrong as the data is there. Any idea what?

Oh right. I forgot that I just iterated over the parameters to figure out what was what.

Looks like there are parameters upto 1,000 (not all are available). Working on creating a list. I don’t get a temp in HA (development tools), but do get a value in the browser. Do you need to run something each time you want it to display? If not, how does it get the session I’d from the command line sensor? When I run it in the browser it expires.

Bill,

The first code snippet in my original post is a python script. Save that in your homeassistant working directory. The script itself gets the session key each time and uses the key to read the oil temperature (the script code I included already requests parameter #18)

Then use the command line platform to call the script. That is the second code snippet in my original post and you can put that in your configuration.yaml file. That will create the homeassistant sensor which you can display on your dashboard.

Hope this helps.

I did all of that. The sensor shows up, but value is unknown.

When you run the script on its own via the command line does it work?

Not sure I understand how to do this? What I did is stored the python script in my custom component directory. I then added the command line sensor to my command line yam filel. This created the sensor when I rebooted. I believe my issue is that the script is not loading / loaded.
I fix my problem. It had to do with the path to the python script.

command: python /config/python_scripts/kohler.py

Works for me. In the first example above it shows a backslash. It needs to be a forward slash.
All working now. Thanks for your help.
Do you want me to post the 230 + parameters available with their display names?
Also any ideas on how to place multiple parameters in the kohler.py (easy) and then create sensors for each?

Bill,

My homeassistant is running in Windows hence the backslashes. Glad you were able to get it to work.

I think the way to go would be to just add an argument to the kohler.py script and then create different sensors for the different parameters you want to capture.

Presumably the more complicated approach would be to create a whole homeassistant integration but I haven’t done that before.

Adam

Thanks again. Not sure how to call the different parameters if I put multiple parameters in the Kohler script. It would be nice to add something that pulls all the data and than add the sensors needed with a template sensor. I know how to create the template sensors, but don’t know how to get all the data. Looks like an intergration is needed. Not sure how to do this either.

Can you just modify the kohler.py file and put multiple parameters in it, i.e. 3,4,18 22, etc. and then create sensors for each?

I think your best bet would be to specify the parameter via the command line and system.argv. Then just specify multiple homeassistant sensors, one for each parameter value.

What is system.argv?

Add a command line parameter to the python script and then use sys.argv in the script itself to read that parameter and use it to retrieve the OnCue parameter value.

A

1 Like

Lots to learn

Since it looks like someone else will find it useful, I uploaded the library I made for this

1 Like