IHC and Home Assistant tips
7 Janurary, 2020
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</code></pre>
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</code></pre>
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 }}'</code></pre>
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.
How to get an enum from IHC into HA
You can get the enum as is current value in text (a string) to a sensor. So you can say it is a of unsupported hack, because the enum is not really supported in HA. In HA is will just be a string. You insert the IHC resource of the enum manually in your configuration.yaml file under the ihc section.
sensor:
- id: 12345
name: myihcenum
unit_of_measurement: "enum"
The HA state of the myihcenum will then be the text value of the IHC enum. Note if you don’t specify a unit_of_measurement it will default to °C – it can be anything you like. It is just a text in the UI.
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.
Comments
The comments below has been imported from the old website. Currently comments are readonly, meaning you can not
make new comments.
You will be able to do that when it is ready. For now if you want to get in touch, you can send me an email.
If you have problems with something that has a github repository, please make a github issue.
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?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)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.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-idsHi Jens,
My question is not related to this post. I'm using the Blinds and Shutters functionblock to control my blinds. Do you know if we can know from HA the "blind state"? I don't see this property in the "IHC Viewer" in HA, but I don't know if it could be easy to do, and If so, and you could give me some tips, I can try it myself.
TakHi Jens,
About my question to know the blinds status I was playing with your PythonIhcSdk, and using the sample.py and I was able to get the "blind state" like this:
Authenticate succeeded
Project downloaded successfully
Runtime value: True
Runtime value: True
Resource change 1632271->Blinds are stopped time: 0:00:02.613724
Resource change 1632271->Blind on its way down time: 0:00:30.252840
Resource change 1632271->Blinds are down time: 0:01:30.308892
But any idea how can I get this info and show it in the Home Assistant UI?
BTW, instead of getting automatically all the switches from IHC I used this code (based on your sample) that generates the code for the configuration.yaml so I can customize the names or add any other attribute.
project_xml = ElementTree.fromstring(project)
groups = project_xml.findall(".//group")
for group in groups:
groupname = group.attrib["name"]
products = group.findall('.//product_dataline[@product_identifier="_0x2702"]')
for product in products:
nodes = product.findall("dataline_output")
for node in nodes:
nodename = node.attrib["id"]
print(" - id: " + str(ast.literal_eval(nodename[1:])))
print(" name: " + groupname + "_" + product.get("name"))
RegardsYou are not the first to ask about enums, so I have added an extra tip above.Thank you very much for your IHC HA integration. I have had my IHc installation for about a year a HA even less so I am still new to it.
I have mapped a push-button to a binary sensor which allows me to toggle an IKEA bulb on and off. Works great. Is it possible to register a push-button being pushed continuously and thus dim the IKEA bulb?
Thanks!I tried doing exactly the same with a Ikea led dimmer, by using the service function to adjust the light up or down while you keep the button pressed. It did not work properly because the Ikea light is too slow to adjust. I only think this can work using the "transition" attribute, and if you can stop the transition. The "transision" attribute is a "parameter" for the light.turn_on and turn_off service functions that will change the light over time. This way you could start a transition from 0% to 100% light over 5 sec when you push the on button, and when you release the button you will stop the transition at the current light level. When I tried it the Ikea integration did not support the "transition" attribute, so it did not work. I think there has been some improvement to this, so it maybe possible to do it that way today.Please give input for the returning notifikation for this one:
Component error: trigger - Integration 'trigger' not found.
Component error: action - Integration 'action' not found.
My code:
binary_sensor:
id: 491868
name: IHC_Tryk_Jonathan_Right
# Manuel indtastning af funktioner/events
alias: MyLightOn
trigger:
- platform: state
entity_id: binary_sensor.IHC_Tryk_Jonathan_Right
from: 'off'
to: 'on'
action:
- service: light.turn_on
data:
entity_id: light.hue_color_spot_1
brightness: 175It looks like you have put the automation part directly into the configuration.
It need to be in the "automation:" section. In a default setup that included from the automation.yaml file.Sorry for late reply.
I'm still learning. Your answer was very helpful. ThanksHi,
Is there any way to invert binary sensors like smoke detector, twilight relay and so on.
I'm running with an auto setup. Really hope you can help.You can insert a "inverting: true" in manual setup - see here:
[HA IHC](https://www.home-assistant.io/integrations/ihc/)
If you have your own ihc_auto_setup.yaml you can also use "inverting: true" (see the first binary sensor as an example).Hi Jens,
Do you know if there is any way of bringing timestamps from IHC into HA?
I have some function block outputs of the type timestamp (called resource_time in the xml file).
I have tried both with manual and auto configuration but I cant find any way that the IHC integration accepts the timestamps.
Thanks for your great work btw.Currently it is not supported, but I will look into this.Sounds great, thanksHi,
Managed to add my IHC push buttons to HA and turn my a Hue light on/off and set brightness. Wuhuu. However, I'm struggling to replicate the smooth dimming from IHC. I followed a HA tutorial, but that implemented a step-wise dimming with a embedded delay in the automation.
Is there a way to achieve this smoothing dimming? - I'm quite noob on IHC
Thanks for great work!There is no way to do as smooth as the native IHC dimming. Doing it is steps is currently the only. Some lights supports a "transition" attribute that can help making is more smooth. I don't know if Hue light supports it.Hello
Is there a way to change a enum from Home Assistant without making a funktionsblok with multiple inputs that then changes the enum?
And also thanks for this integration in HA - it is very nice!As I understand your question you are asking for a service function in HA like for integers: ihc.set_runtime_value_int, but for enum "ihc.set_runtime_value_enum". It is not something I have implemented yet, but I will make a note of it. HA does not have "native" enums so it would be just a text in HA.Yes sorry for being a little cryptic with my question, I think it could be nice to have that control over funktionsblokke in HA. And yeah I could imagen it would be some non native way to make it work, but if it is possible it would be awesome!And also, does the set_runtime_float work for setting time values?I don't think it works currently because the type are not converted. You can read timer values if your add it as a sensor in HA - it will be show as miliseconds. A "time of day" in a sensor will be shown as hours:minutes:seconds
(Note the timer values as sensors are not present in the current HA version, but will be when I make a new update)Hi!
Just a double check - I can see timer values and have added a few sensors in a dashboard but they are not updated so I just want to check if I just need to wait for an update of HA?
The same goes for IHC Alternate Service Viewer, the timer values are emptyYou should get it from the ["beta" version](https://www.dingus.dk/help-testing-the-new-home-assistant-ihc-integration/). There are 2 time types in ihc: "time of day" - as hh:mm:ss, and a "timer time" that is the time as a dicimal number in seconds.
Both should update in HA when changed in ihc. What is currently in the "beta" will go into the official version when it is updated.Hi!
It works perfectly. My bad, I used a rsource ID which was not used..
Really great work from your side. Thanks!Håber det okay jeg skriver på dansk. Er det muligt og kalde et IHC tryk via Home Assistant. Har forsøgt med Service IHC Pulse og det Rescource ID mit tryk har.Ja det er muligt - du kan teste i HA Udviklerværktøj|Tjenster - vælg ihc.pulse i dropdown - tryk udfuld eksempeldata - erstat 123456 med dit resource id for knappen og tryk kald tjenste.
(Bemærk at hvis du har flere IHC controllere så virker service funktionerne i nuværende version kun på den sidste controller du har i din opsætning)Tak for svaret.Det virket. Du har ved tilfældigvis ikke om der kommer en løsning i forhold til at kunne styer ihc dimmer 350 lr ?Problemet med dimmer 350lr (og unidimmer 350/400) er at der ikke er noget "feedback" til ihc controlleren så den kender ikke status for dimmeren (tændt/slukket, lysniveau). Du kan stadigvæk tænde/slukke ved at sende en puls til din funktionsblok i IHC der styrer din dimmer, men du kan ikke styre lysniveau. Bemærk du skal ikke sende puls direkte til din dimmer - fordi længden kan variere og så blive opfatte som et langt tryk. Og hvis din funktionsblok har et lysindekerings output ON/OFF kan du bruge det til at angive om lyset er tænd/slukket. (Det kan så ske at det ikke viser rigtigt hvis din IHC controller kommer ud af sync med din dimmer)Hvilke dimmer vil du anbefale jeg udskifter mine gamle dimmere til. Hvis det er dimmer som stadig skal side ude i tavlen ?Jeg har selv kun wireless dimmere. De gamle wireless har det ikke godt sammem med led - skal have en belastning på min 20W (så vidt jeg husker).
Jeg tror den enste tavle dimmer med "feedback" er den nye 2 kanals led dimmer, som sidder på RS485. Den virer kun dog med den nyeste Visual 3 controller. Så hvis du har den nye controller er det nok den jeg vil vælge.Jeg har desvære en ældre controler. Er der nogen løsning på jeg kan undlade at bruge dimmer funktionen i mit IHC uden jeg skal afmontere dimmerne i tavlen. Så de vil fremgå i HA som et almindeligt lampeudtag on/off.Jeg ved ikke hvorfor jeg har fået så mange der spørger til de gamle dimmer lige nu men jeg har lave en spcial post her: [Home Assistant and IHC Dimmers](https://www.dingus.dk/home-assistant-and-ihc-dimmers/) som forklarer det.Hvad er syntaksen til ihc.pulse?
Vil gerne sende et on efterfulgt af et off tryk til IHC.
Kan ikke få ihc.pulse til at virke.Hvis du i Home Assistant går til "Udviklerværktøjer|Tjenster" - vælger ihc.pulse i "Tjenste" så vises parameter i bunden.
Der er kun en parameter "ihc_id".
Bemærk at det ikke virker hvis du har mere en en IHC controller - jeg har et pull request til HA som gerne snart skulle komme med. Der er også opdateret HA dokumentation her: [HA IHC integration](https://github.com/dingusdk/home-assistant.io/blob/next/source/_integrations/ihc.markdown)Lækker tutorial.
jeg fulgte den for noget tid tiden og fik fint sat target temperatur på min varmestyring for noget tid siden, med en jinja2 formel lignende din {{ states..}} .
Jeg har lige opdaget af det ikke virker længere med ihc.set_runtime_value_float.
når jeg skyder service-kaldet af i udviklerværktøjer->Tjeneste skriver den expected float in dict @ data['value']
Hvis jeg skriver et tal direkte ind, så virker det.
Er der noget med implementeringen af data_template?
/MartinDet kan være fordi "value" ikke er en float - du kan konverter ved at skrive |float bagefter dit template udtryk.Tak for buddet.
Min formel ser sådan ud:
{{ states.climate.vaerelse1.attributes.temperature | float }}
Jeg har prøver med approstrof på leder og kanter. Det der undre mig er at det har virket. Er dit kald defineret med data eller data_template? Mit climate control er en ‘generisk template’, som måske kunne spille ind?
Tak.Jeg tænker at det er noget der er lavet om i template koden. Hvis det virker for dig fra Udviklerværktøjer|Tjenster - så er problemet ikke i IHC integrationen. IHC inetgrationen definere en funktion set_runtime_value_float der tager et ihc id og en float værdi - resten ligger udenfor i Home Assistant. (d.v.s IHC integrationen har ikke noget med om det er data eller data_template)
Jeg bruger set_runtime_value_float til kopiere en temperatur fra en termostat til IHC og det virke stadigvæk.Super god integration, men jeg har desværre fået et problem
Setup failed for ihc: Integration failed to initialize.
21.41.21 – setup.py (ERROR)
Unable to read project from IHC controller
21.41.21 – ihc (ERROR)
Jeg tror det er kommet efter den seneste opdatering. Jeg har også forsøgt at installere en ny version af HAS, men får samme fejl.
Min konfiguration er som følger:
ihc:
- url: 'http://192.168.61.6'
username: user
password: pwa
Jeg kan se på IHC administratoren at brugeren har været logget ind, så det er nok som log'en siger problemer med at læse projektet.
Hvad kan der være galtNår du siger opdatering - mener du så Home Assistant?
Fejlen "Unable to read project from IHC controller" betyder at authentication er gået godt - d.v.s. brugernavn/adgangskode login er ok, men at IHC projektet ikke bliver læst fra controlleren. Der har været nogen versioner af IHC firmware som har givet den fejl. Hvis du har den nyeste IHC firmware (eller ikke har ændret den siden det virkede), så prøv at genstarte din IHC controller (og vent til du er sikker på at controlleren er oppe og køre igen) og genstart derefter Home AssistantDet virkede tak!
Og ja, det var en opdateret Home Assistant, men IHC controlleren kører på hw 6.2 med lidt ældre firmware.Is there a way to control covers/shutters from HA and IHC, I have tried cover_template and HACS cover_time_based_synced, but it does not work.
It is not possible to control it with 2 buttons connected to HA
thank you very muchI don not have any covers/shutters in IHC myself. I do have a garage port in IHC and I control this with the HA cover template integration. You should be able to do the same. You set the value_template to a binary sensor from IHC that has the state of your shutters (open/close -> on/off You need to add the binary IHC resource manually). The you use the open_cover and close_cover the call the ihc.pulse service - to "press" the buttons in IHC to open/close the shutters.Fantastisk arbejde du har lavet/laver med integrationen til Home Assistant. Tak for det!
Er der en måde at binge IHC's Hjemetilstand med over i Home Assistant?Hi Jens
How to adjust only the set-temps in the functionblock in IHC from HA?
TomasHi Jens,
since updating HA on 3rd of May my (enum) IHC sensors are not working any longer. I found out, that this is because my sensors do not have integer values.
I had working enum sensors like Cover state (open, closed, ...), Tim sensors like sensor.ihc.sunset which was the time when the ihc lightsensor switched to night.
If I give the sensor an integer Value (via ServiceView) HA display it.
How can I get my sensors working again?
_______________________________
IHC visual 6.1 running V2.7.220
HA 2023.5.3 (10.1)
IHC integration via config.yamlThis is because of a change in HA. Ha now expect all sensors with a unit of measurement to be a number, and it is not sufficient to just make an empty unit of measurement. I have alread made a pull request for the official integration. I will make an update for the "beta" version (or probably better to call version 2.0), very soon.Thanks a lot for your gewat work.
Meanwhile I consider having numeric Cover states (o=open, 1=closed, 2=sun).
But bringing back the ids with time woulg be great.Hi Jens,
Do you know if it is possible to get "Double click" and "Long click" on the IHC buttons?
To work in HA
Thanks
Regards
CLAUSI assume you want to trigger an automation in HA when you double click or long press. The best way is to have an output on/off in your IHC function block that will go on and off (pulse) when you double click or long press the ihc button. Connect this output to HA as a binary sensor. Then you can trigger an automation when the binary sensor goes on and do whatever you like.