Customizing Home Assistent IHC auto setup

I have had some questions about the auto setup of IHC in Home Assistant, and since this is not described on the Home Assistant documentation pages, this post will be about how you can customize the auto setup.

How does the auto setup work?

The auto setup is done by searching in the IHC project for patterns of predefined component. The IHC project file is a XML file. The search is done using xpath (this is a standard expression for selecting nodes in XML). I will not describe it further here, you can do a search for xpath tutorial in google and you can find plenty of information about it. The home assistant IHC integration has a predefined ihc_auto_setup.yaml file in the homeassistant/components/ihc folder. This file already has setup for the most commonly used products. The file has a section for binary_sensor, sensor, light and switch. All have the 2 variables:

xpath
The xpath expression to find the product

node
The name of the xml node containing the resource to map into home assistant

Below is the platform specific variables for binary_sensor, sensor, light and switch.

binary_sensor

The IHC resource (refereed to by node) most be a boolean resource (on/off)

Inverting
Boolean (True/False)

type
The binary sensor type in home assistant. Look in Home Assistant Binary Sensor for a list of build in types. (device classes)

sensor

The IHC resource referred be the node can be a integer of float resource.

unit_of_measurement
The unit of measurement to be used in Home Assistant

light

dimmable
Boolean (True/False). Set to True if the light is a dimmer. If you do not set this and the type of the resource is a integer (light level in the IHC project) the light will also be a dimmable.

switch

Has no additional variable, The resource should be a boolean (on/off)

Customizing the auto setup

The first step is to copy the ihc_auto_setup.yaml into your configuration folder. If the configuration folder contains a ihc_auto_setup.yaml file this will replace the build in file. If you can not file the file (or have a docker installation where the file is more difficult to access), you can get is directly for the home assistant github page

Open the ihc_auto_setup.yaml file in whatever editor you use for yaml files.

Removing products from the auto setup
Find the product you don’t want and delete all the lines from “- xpath” under the product. Each product has a comment describing what it is. After making change to the auto setup you have to restart home assistant.

Adding a new product to the auto setup
Create a new IHC project only containing the product you want to used for auto setup. This makes is easier to identify in the project file. Save the project file and open it on a text editor, preferable one that can show xml syntax (or a browser)

I will give and example adding the an actuator ( “telestat” in danish – my ihc applications are in danish – and screen dumps will be in danish)

Looking in the saved ihc project we can find the “Telestat”:

<group id="_0x2132" name="Stue" icon="_0x15">
  <product_dataline id="_0x5153" product_identifier="_0x220a" name="Telestat" locked="yes" icon="_0x84">
    <dataline_output id="_0x525b" name="Udgang" backup="yes"/>
  </product_dataline>
</group>

Now we need to write an xpath expression to select the product_dataline node. It is a good idea to have some kind of xpath tester when doing this. You can use an online tool like this xpath tester In the XML section paste the complete IHC project. In the xpath field write an xpath expression:

.//product_dataline[@product_identifier=”_0x220a”]

If you look at the above xpath you can see it is similar to some of the other xpath expressions from the auto setup. The only difference is that it has another product_identifier. Clicking the “test” button in the xpath tester we can see it will find the xml node we are looking for. We can also see the child node for the resource is the “dataline_output”, so that will be the “node” in the auto setup.
If you want to make sure the xpath expression does not find too many nodes (nodes you don’t want), it is a good idea to also test with a full IHC project in the xpath tester.
If we want to add this as a binary_sensor we will have:

- binary_sensor
    - xpath: './/product_dataline[@product_identifier="_0x220a"]'
      node: 'dataline_output'
      type: 'heat'

We could also have added the actuator as a switch is case we want to control it from home assistant. To do this you just move it to the “switch” section of the auto setup file, and remove the “type” variable.

Notes on editing yaml

When I stated using Home Assistant the most frustrating thing was the yaml files (I am still not a big fan, but I can live with it). To make it less frustrating make sure you have an yaml editor that can validate it and have syntax highlighting (Like Visual Studio Code with a yaml extension)

Secondly use the “Config validation” in home assistant before you restart home assistant

6 responses to “Customizing Home Assistent IHC auto setup”

  1. mando says:

    Hi !

    Great info. Thank you.
    A side note – I have a fresh docker installation of Hassio.
    For some reason, no dimmers shows up, only switches

    Should I manually do an own config update somewhere?

    • Jens says:

      What kind of dimmers do you have? All the wireless dimmers should be found by the auto setup. The dataline dimmers are not in the auto setup. I did not include any of these because I don’t have any to test it. And it looks to me like they do not have feedback so the IHC controller does not know the current lightlevel.
      If you are missing something you can add it like described in this post.

  2. mando says:

    Hi,
    They are wireless.

    From my .vis file:

    <product_airlink id="_0x4b854" product_identifier="_0x4305" device_type="_0x80a"

    • Jens says:

      This product is not available in the danish LK Visual! I downloaded the Elko Visual software and can see it has more products than the LK version.
      If you look the folder where you have installed the visual program, you can find a .def file for each product – the dimmer is in this “Products\02#Trådlösa (WL) produkter\03#WL Mottagare – dimmer” folder. The Elko version has product4301 to 4308. The LK version only 4303, 4304 and 4306. I will update the default auto setup file in HA when I have something else to update.
      Until then you can edit the auto setup as I write about in my post above. It should be easy – you can use one of the existing wireless dimmers as a template and replace the product id with _0x4305

Leave a Reply

Your email address will not be published. Required fields are marked *