IHC and Home Assistant tips

In this post I will give some tips about the most asked questions I get for IHC and home assistant, and include examples I have used in my own setup. Basically it is about how the get something from IHC into HA or the other way.

How to turn on Philips hue light (or some other Home Assistant light) using an IHC push button.

The question is often: how do I get my IHC push button into HA? and the short answer is you don’t because HA does not have push buttons – only switches, and that is not what you want. What you want is something that can show the on/off state of the button and trigger an automation when the state changes. For this we have the binary sensor in HA.

First step is to make a binary_sensor for the push button. You do this by manually adding it to the configuration.yaml

ihc:
  ...
  binary_sensor
  - id: 2382609
    name: mybutton

Name the “mybutton” button whatever you like. You can now see the button in HA as binary_sensor.mybutton. We want to have the button turn on a light called “mylight”. You add an automation to trigger when the button is pressed:

alias: MyLightOn
trigger:
 - platform: state
   entity_id: binary_sensor.mybutton
   from: 'off'
   to: 'on'
 action:
   - service: light.turn_on
     data: 
       entity_id: light.mylight
       brightness: 175

To configure another ihc button to turn off the light is almost the same, you just replace the light.turn_on with a light.turn_off. Note the “brightness” here is if you have a dimmable light. If the light is a simple on/off your can remove it.

Use a sensor from HA in IHC

IHC does not have wireless sensors like temperature or motion. I have temperature from my heating system (MaxCube) and also some zigbee temperature/humidity and pir sensors.

In this example I want to have a temperature sensor from HA and use it inside IHC. The following automation will trigger when the temperature changes and set the temperature on a float resourse in IHC

- alias: RoomTemperature
  trigger:
  - platform: event
    event_type: state_changed
    event_data:
      entity_id: climate.termostat
  action:
  - alias: CopyTemperature
    service: ihc.set_runtime_value_float
    data_template:
      ihc_id: 2210580
      value: '{{ states.climate.termostat.attributes.current_temperature }}'

In this case is the temperature from a climate entity and I use:

 {{ states.climate.termostat.attributes.current_temperature }}

If is was a temperature sensor called “mysensor” it would be

 {{ states.sensor.mysensor.attributes.temperature }}

I HA use the “Developer tools”, States to see the specific attribute for your sensor, it may not be the same.

I use ihc.set_runtime_value_float because temperatures i IHC are float values. The resource id can by any input or output resource on a functionblock in IHC. The type must match the service function, so if you have a pir on/off you use the ihc.set_runtime_value_bool (and the IHC resource should also be a boolean on/off)

The same pattern can be used when you want to use something else from HA inside your IHC function blocks.

Notes

When working with templates it can often end in a lot of restarting of HA until the template expression is right. It is a good idea to use the “Template” under “Developer tools” to check your template – then at least you know the syntax is correct before you try it.

4 responses to “IHC and Home Assistant tips”

  1. Christian says:

    Hi, thanks for some great tips and tricks. I don’t know, if this is the right place for this comments – if not, I apologize. Do other also have the issue, that IHC entities show up with: “This identity does not have a unique ID” under setting for the identity? Any solution for this?

    • Jens says:

      I already replied to you on this comment: https://www.dingus.dk/home-assistant-ihc-integration/#comment-408
      Because that was in danish, I will write it here again for others to read. The unique id functionality was not available at the time when the IHC integration was made, it is a newer thing added lately. I currently don’t plan to add it because as far is I know the only thing you get is the ability to hide the entities. The unique id’s are part of the new integration configuration i HA. It would be nice to have that for IHC (could allow you to configure the connection the IHC controller from the UI), but it is more a nice to have, than a need to have (and I currently don’t have to time to do it)

  2. Ejvind Hald says:

    Hi Jens, thank you very much for this great integration and tips for using it.
    It is cool and I assume you have spend a lot of time on it.
    I like that you added the on and off pulse option, so function blocks can be activated inside IHC.

    Clearly, as this something done when you are off work, your time is limited. If you some day get time, I would also like to vote for the unique id. It seems that some mqtt functionality is now connected to unique id – see https://www.home-assistant.io/integrations/switch.mqtt/

    Thanks again.

    • Jens says:

      Yes – this is a spare time project for me, (and I have a lot) so I need to prioritize. The unique id is not on in the top of my list. The mqtt integration use the unique id like some other integrations do, but that has nothing to do with the IHC integration. The unique id is for integrations that has a configuration flow (User interface), and where the integration can discover new devices automatically. It allows the integration to register devices and the user can choose to ignore a device. https://developers.home-assistant.io/docs/config_entries_config_flow_handler/#unique-ids

Leave a Reply

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