Import of Homematic System Variable in Home Assistant

I have configured Home Assistant in a docker container on a Ubuntu system. My Homematic devices are setup on a separate raspberrymatic machine.
I succeeded in importing data in Home Assistant. My configuration can be found in:

I have now the following question:
Is it possible to import data defined in a system variable? In the Homematic forum I found a way (by means of a small program) to put data of the valve position in this system variable. I was interested in logging (in Home Assistant) the valve position.
In the data imported from Homematic you can also find valve position data. But I find always a value of 4% also if a close or open the valve totally.

You can create a template-sensor that keeps track of the valve position like this:

- platform: template
      value_template: '{{ states.climate.leq123456.attributes.valve }}'
      friendly_name: 'My Valve'

This value should always represent the current state of the valve. If it stays at the same value, then probably the valve just didn’t move.

I carried out already your proposal.
In the RaspberryMatic and in CCU-Historian I can observe a change of the valve position, but not in the template-sensor within home assistant. Within home assistant I always find a value of “4” independent of the real valve position!. When I press on the boost button in the RaspberryMatic UI, the programmed system variable is going to 0.8 in both the RaspberryMatic UI and CCU-Historian but the value stays on “4” in home assistant.
Can it have to do with the fact that I have Homematic IP?

I don’t think this is related to Homematic IP. Maybe recently a bug was introduced. Now that it’s summer I haven’t really looked at the valve states honestly. I’ll check who my system operates when I find the time.

Did you already check your system concerning valve position logging?

Just had a look. My tempate sensor works fine. Within the last 24 hours it had values between 0 and 99. So technically this should be working. But this is for a non-IP device. I don’t have IP devices to verify if they work the same way. But if devices have the valve position in their attributes, a template sensor should work just like in the example.

As I wrote before the sensor VALVE_STATE (as indicated in Raspberrymatic) or valve (as indicated in Home Assistant as attribute) both indicate a value 4. In all situations!
From the Homematic community forum I found that it is possible to define a system variable of the valve position.
Now I found that it is possible to import the data in Home Assistant by means of mqtt. To make that possible I installed a rather new additional software for the Raspberrymatic called Redmatic.
So problem solved.

You can also access variables directly if you add your RaspberryMatic as a host similar to this:

      username: Admin
      password: secret

With that you get an entity for your CCU with has all variables as attributes. Those variables get updated every minute.

You are right!
I obtain the following data:

${sysVarAlarmMessages}: 0
${sysVarPresence}: true
${sysVarServiceMessages}: 0
DutyCycle: 4
Klepstand Overloop: 0
Klepstand Werkkamer: 0
friendly_name: ccu2
icon: mdi:gradient

I find the valve positions under “Klepstand Overloop” and “Klepstand Werkkamer”.
THe other data are not so interesting I think.