Homematic Modul: Read/Write system variables

Hi there.

I am tinkering a lot with Home Assistant lately.
I am also using Homematic as the main part of my setup.

I am just wondering: since there is no integration of the CCU2 system variables in HA yet (read+write), are there any plans to do so?

Would be great if this would be implemented.

(or is there a known workaround yet?)

Thanks!

The manual says: variables (Optional): Set to true if you want to use CCU2/Homegear variables. Should only be enabled for the primary host.

But i didnā€™t get it to work for meā€¦

i have the same Problem. No variables :frowning:

There was a bug in prior versions. If you update to 0.37.1 You should get a CCU entity, which has all the variables as itā€™s attributes. Thatā€™s a little bit different from the documentation, because before we noticed this wasnā€™t working it was implemented differently.
Whatā€™s missing from the documentation as well is, that when you use a CCU (so not Homegear), youā€™ll also have to specify the API password of the CCU. Otherwise the CCU rejects the requests HASS is making to check out the variables.

I will update the documentation soon. Until then try out the latest version and have a look at the homematic.set_var_value service (which is used to set bool and numeric variables on the CCU).

1 Like

i can see in the GUI all Homematic switches and sensor . Alle variables are not displayed. Have you a tip for me?

i have installed a new jessie + Raspberry Pi All-In-One Installer (Version 0.37.1).

Edit the configuration.yaml with:

homematic:
hosts:
wireless:
ip: 192.168.0.6
resolvenames: json
username: guest
password: xxxx
primary: true
variables: true

The variables are, opposed to what it says in the documentation, NOT displayed as single entities. Somewhere in the frontend you should see one single entity named ā€œwirelessā€. if you click on that, the element will open and you should see the entities as the attributes.

To use them in automations you have to use templates. I will update the documentation on the weekend and include an example.

1 Like

Thanx for the response. i look forwardā€¦

Iā€™ve updated the documentation. Since it still is a pull request you can view the updated documentation here:
https://github.com/danielperna84/home-assistant.github.io/blob/c874a93bbc304759e3833da20cfcfc39cda66850/source/_components/homematic.markdown

Thank you for your work, but i donā€™t get a result. Sorry, obviously i need e specific example to get display one variable from homematic in the GUI.

Thanx for your help
Oliver

What kind of device are you trying this with?

In general hereā€™s how it works.

If it is a non-boolean variable:

sensor:
- platform: template
  sensors:
    bedroom_valve:
      value_template: '{{ states.climate.leq123456.attributes.Valve }}'
      entity_id: climate.leq123456
      friendly_name: 'Bedroom valve'

And if it is a boolean variable:

binary_sensor:
- platform: template
  sensors:
    frondoor_battery:
      value_template: '{{ states.binary_sensor.meq123456.attributes.Battery == "Low" }}'
      entity_id: binary_sensor.meq123456
      friendly_name: 'Frontdoor battery'

You can experiment with templates in the HASS UI. On the lower left there are 5 buttons. The second one from the right (the two angle brackets on grey background) takes you to an interactive template editor. Thereā€™s a textarea with some demo-code in it. and the result is shown on the right. There you can paste in the template from one of my examples above, and on the right the result should be displayed. So for example:

{{ states.binary_sensor.leq111111_state.attributes.Battery == "High"}}

Shows True as a result on the right side, which tells me that the battery of the shutter contact is ok. For logic reasons and possible unkonwn states while HASS is starting, Iā€™ve used == "Low" in my sensor-example above. That would create a binary_sensor entity, which is always in off state for as long as the value of the attribute is not High.

An alternative way of doing what Iā€™ve done in the sensor example:

{{is_state_attr('binary_sensor.leq111111_state', 'Battery', "Low")}}
1 Like

Much easier but i canā€™t get it.

I want to display a homematic variable. For a example var1. The value of var1 can be Ja or Nein. My Question is how can i display the value (Ja or Nein) from var1 in the HA GUI?

The tip wth the interactive template editor is very good.

Thanx for your help.

First thing to do would be to find the CCU entity in your frontend. When I click on mine, it looks like this:

In my case I have configured the host for wireless devices to have the name ā€œhmrfā€. And as you see in the screenshot I have a variable called ā€œTestvariableā€.
The template I use looks like this:
{{ states.homematic.hmrf.attributes.Testvariable }}
If I paste that code into the template editor, False is displayed on the right side, just like in the CCU entity.

In your case Iā€™m not sure if you really have a boolean variable. On my CCU the variable is defined like this:


But youā€™re saving your variable is either ā€œJaā€ or ā€œNeinā€, which indicates that youā€™re using something different. Although that shouldnā€™t matter. In that case you would just adjust the template to test something like {{ ...blabla == "Ja" }} or so.

1 Like

I take a CCU variable boolean AN1 with the values ist wahr or ist falsch.

When i click on the ccu it looks like this

It looks different than you screenshot. There are less information. Then i check the template.

There ist no error but also no value!?

Have a look at your error logs (of HASS). You probably havenā€™t configured the homematic compoent correctly. As no variables are shown in the entity, it fails to load them.

In the error log i see only this error with pyhomemanic:
[pyhomematic.devicetypes.generic] HMGeneric.getValue: GAS_POWER on MEQ0381684:1

My configuration.yaml for the component homematic:

homematic:
hosts:
rf:
ip: 192.168.0.6
resolvenames: json
username: guest
password: olftob
primary: true
variables: true

In that case I suspect, that a guest user is not sufficient and you need a user with admin-privileges.

With admin-privileges was the solutions, great.

Now i have with the interactive template editor the correct result.
{{ states.homematic.rf.attributes.AN1 }} < false

That looks good.

Now i have Problem with the last step. Sorry i am new with HA.

Here is the part from the configuration.yaml

binary_sensor:

  • platform: template
    sensors:
    Paketannahme:
    value_template: ā€˜{{ states.homematic.rf.attributes.AN1 }}ā€™
    entity_id: homematic.rf
    friendly_name: ā€˜Paketannahmeā€™

And this ist the result in the GUI

I think that is a easy question for you :wink:

Actually no, I donā€™t know what the problem is in that case. Have a look at the log or test your configuration using the check_config script. Maybe this will give you a hint what the error could be. I would guess itā€™s a syntactical problem, but I canā€™t tell without seeing the proper indentation. You can post formatted text here in code-blocks. Start and end a code-block with 3 backticks (Grave accent). Like this, but with the correct character (other direction):

Ā“Ā“Ā“
codeblock
Ā“Ā“Ā“

The sensors name with ā€œPaketannahmeā€ was not correct.

Now i have the homematic variable in the GUI. The case ist closed

Thank you very much for the help!!
Oliver

binary_sensor:

  • platform: template
    sensors:
    Paketannahme:
    value_template: ā€˜{{ states.homematic.rf.attributes.AN1 }}ā€™
    entity_id: homematic.rf
    friendly_name: ā€˜Paketannahmeā€™
1 Like