Press "Enter" to skip to content

Posts published in “Home Assistant”

Controlling the Elecraft K4 and KPA1500 with Home Assistant

For awhile now I have wanted to be able to have my “Goodnight” scene in HomeAssistant turn off my network attached ham gear. I finally had a chance to do some experimenting and created this config to turn on and off the KPA1500.This sends a command via UDP to the amp to turn it off and uses Wake_On_LAN to turn it on. A similar thing could be added for other device types. This is added to the configuration.yaml file.

Put your real MAC address of the amp next to mac. If you mac address is 54:10:01:02:0A:0B, then the line will read mac: 54:10:01:02:0A:0B

switch:
– platform: wake_on_lan
name: Elecraft KPA1500 Amplifier
mac: 54:10:01:02:0A:0B
turn_off:
service: shell_command.turn_off_kpa1500shell_command:
turn_off_kpa1500: “echo ‘^ON0;’ | nc -u 192.168.1.2 1500”

It assumed the IP address of your amp is 192.168.1.2 and it is listening on the default port 1500. Note this is a UDP connection so the command is sent with netcat (nc). ^ON0; turns off the amp. Reference to wake_on_LAN in HomeAssistant is here: https://www.home-assistant.io/integrations/wake_on_lan/. This also assumes you are on the same network as the amplifier.

If you are doing this from a script on a Raspberry PI for example, you can use etherwake (sudo apt-get install etherwake)

Now for the K4…
Since the K4 does not yet support Wake_On_LAN, you have to resort to the old ways to remotely turn on the radio. But once the radio is on, then HA can check the status and allow you to turn it off. So for my use case, I can send a command to the radio to turn off as part of my ham shack off scene (goodnight).
In the switch section of the configuration.yaml, add the following:
– platform: telnet
    switches:
      k4:
        name: “Elecraft K4 Transceiver”
        resource: “192.168.1.108”
        port: 9200
        command_off: “PS0;”
        command_on: “PS1;”
        command_state: “PS;”
        value_template: “{{ ‘PS1’ in value }}”
        timeout: 0.9

Connecting a Kohler Generator to Home Assistant (work in progress)

*** There is now an Add-On for the Kohler Generator. ***

I have been playing around with Home Assistant (HA). Briefly, it is a management system for IoT and other devices that is hosted internally (on a Raspberry Pi in my ham shack). With Home Assistant, it is natural to look for all the things that are already programmed to connect with and check their status. I already have the following items in Home Assistant:

  • Lutron Caseta Switches
  • Wemo Switches
  • Rain Machine Sprinkler Controller
  • Honeywell WiFI Thermostats
  • Pi-Hole
  • SensorPush temperature and humidity monitors
  • Insteon Plugs
  • Samsung TVs
  • HP LASERJet printer
  • Ring Doorbell
  • Synology DSM
  • UniFi UDM Pro

One device I was curious if I could connect is our Kohler 24KW generator. The Kohler generator has an Ethernet jack on it which is connected into one of my isolated VLANs (lest someone open the generator and try to get into my network–same idea for the wired Ring doorbell). Kohler uses its own cloud service called OnCue Plus to collect state on the generator and control it. In researching this, I found a page that described the authentication call followed but the call to get the state of the generator. This was posted by Russell Salerno in March of 2018. It seems easy enough to write some code for HA to periodically poll this API. Of course, getting into the details of this to control the generator will require some reverse engineering as I do not believe Kohler publishes an API.

The site I found the info was here: https://community.openhab.org/t/looking-for-an-easy-binding-template-to-write-a-binding-for-kohler-generator/42120/2

I am recreating the data here in case it disappears:

The protocol is straightforward:

Step 1: Get session key if none is available.

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

This returns some json elements, one of which is a session key. Use the session key to get current status of the generator.

Step 2: Get generator status using session key

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

The numbers are data elements that correspond to items of interest. A complete table of these items is here (again from Russell’s post).

I will update this post as I make some progress and learn how to code up my own Home Assistant integration.