Homematic IP Local: read state of system variable

Hello,

I am using a Homematic CCU3 with Respberrymatic and have got a system variable on the ccu3 which I want to read the state of to a sensor. I am using the custom component Homeamtic IP Local in HA. this is what I have in configuration.yaml:

sensor:
    - platform: template
      sensors:
        alarm_scharf:
           value_template: "{{ state_attr('homematicip_local.ccu3_webui','Alarm_Notfalltüren_scharf') }}"
           entity_id: homematicip_local.ccu3_webui
           friendly_name: "Alarm Notfalltüren scharf"

I am not sure if the entity_id is correct, the device names from the list in HA is not the right one, what do I have to use here ? do I have to fetch the system variables from HM before the value_template ?

regards
Stefan

actually this is my second attempt, not working:

binary_sensor:
    - platform: template
      sensors:
        alarm_scharf:
           value_template: "{{ state_attr('homematicip_local.hmip_ccu3_001F9D89909069','Alarm_Notfalltüren_scharf') }}"
           entity_id: homematicip_local.hmip_ccu3_001F9D89909069
           friendly_name: "Alarm Notfalltüren scharf"

read in the README of the component no “hahm” marker in description in system variable is needed for a binary sensor. still not sure if entity_id is correct.

an ai system proposed the following:

binary_sensor:
    - platform: template
      sensors:
        alarm_scharf:
           value_template: "{{ states.homematicip_local.ccu3.attributes.system_variables.Alarm_Notfalltüren_scharf }}"
           friendly_name: "Alarm Notfalltüren scharf"
           device_class: door

but is not working, any ideas ?

The entity ID should be listed under Settings - Devices & Services - Integrations - Homematic(IP) Local.
For a Template Sensor I think it should look like this:

template:  
  - sensor:
      - name: "Alarm Notfalltüren scharf"
        unique_id: alarm_scharf
        state: "{{ state_attr('homematicip_local.hmip_ccu3_001F9D89909069','Alarm_Notfalltüren_scharf') }}"

I’m no expert on templating so I’m not too sure what you are trying to achieve. You could try using the Template Editor under Developer Tools to verify your template.

hey sota, thanks for replying. the code is sadly not working. “state” is not allowed at that point.
hmip_ccu3_001F9D89909069 is the device id of the homematic ip local ccu3, I checked that.

I am trying to implement a sensor which shows in the UI if the alarm is switched to poteniially on or off. maybe there is an easier way of showing the state of a HM system variable on the HA UI.

the event string in the template editor for my example is showing the following:

binary_sensor:
    - platform: template
      sensors:
        alarm_scharf:
           value_template: "None"
           friendly_name: "Alarm Notfalltüren scharf"
           entity_id: homematicip_local.hmip_ccu3_001F9D89909069

So the value_template is undefined. that’s the rease why I think the device id is wrong maybe.

state_attr is working on an entity and not on an device. Where did you find the attribute or why do you thing that there is an entity with this attribute?

BUT The custom component Homeamtic IP Local has the system variable already directly as entities. Just activate them on the device (there might be more than one CCU devices, search for the hidden SV in all of them). Here e.g. you can see one own SC Dutycycle (not needed anymore), so not activated.

image

I tried it with the entity id also, not working.
the hint with the hidden SV system variable was good, trying to make it working on the UI.

Edit:
I had to add “hahm” to the description of the variable on the ccu3, now I can switch it on and off on the UI. thanks for helping.

Open the developer tools in HA and then look at the states tab there to find your entity.

thanks WallyR that was also a good hint, I found the name of the variable switch and can check the state of the switch:

condition:
  - condition: state
    entity_id: switch.pps_sb_ccu3_sv_alarm_notfallturen_scharf
    state: "on"