Homematic: Way to retrieve System Variables with spaces (value_template issue)

Hi community,

currently, I got this configuration:

homematic:
  interfaces:
    rf:
      host: 10.0.0.222
      username: Admin
      password: Passw0rd!
      resolvenames: json
    ip:
      host: 10.0.0.222
      port: 2010
      username: Admin
      password: Passw0rd!
      resolvenames: json
  hosts:
    raspberrymatic:
      host: 10.0.0.222
      port: 2001
      username: Admin
      password: Passw0rd!

binary_sensor:
- platform: template
  sensors:
    hmipanwesenheit:
      value_template: '{{ states.homematic.raspberrymatic.attributes.Anwesenheit == true }}'
      entity_id: homematic.raspberrymatic
      friendly_name: 'Anwesenheit'
    hmipanwesenheitandreas:
      value_template: '{{ "states.homematic.raspberrymatic.attributes.Anwesenheit Andreas" == true }}'
      entity_id: homematic.raspberrymatic
      friendly_name: 'Anwesenheit Andreas'
    hmipanwesenheitstefanie:
      value_template: '{{ "states.homematic.raspberrymatic.attributes.Anwesenheit Stefanie" == true }}'
      entity_id: homematic.raspberrymatic
      friendly_name: 'Anwesenheit Stefanie'

sensor:
- platform: template
  sensors:
    hmipdutycycle:
      value_template: '{{ states.homematic.raspberrymatic.attributes.DutyCycle }}'
      entity_id: homematic.raspberrymatic
      friendly_name: 'Duty Cycle'

I am trying to retrieve two system variables with spaces in the name. I know that I could just rename then, however that would look not that good on homematic site.

These are the value templates i already tried:

'{{ states.homematic.raspberrymatic.attributes.Anwesenheit Stefanie == true }}'

-> Results in an error during Startup

'{{ states.homematic.raspberrymatic.attributes.Anwesenheit\ Stefanie == true }}'

-> Same

Anybody got an idea?

This is how the entity looks like:
image

This is the Homematic WebUI (however this shouldn’t really matter here)

Keep in mind that the retrieval of the DutyCycle and Anwesenheit are working fine for me.

Cheers

Andreas

Try is_state_attr():

'{{ is_state_attr("homematic.raspberrymatic", "Anwesenheit Andreas", true) }}'

Yet using space in keywords or even non-ASCII characters is still an issue (even in 2021).

1 Like
"{{ is_state_attr('homematic.raspberrymatic', 'Anwesenheit Stefanie', true) }}"

Edit: too slow xD

1 Like

Thanks a lot mates, my OCD is relieved :smile:

That solved the problem.

Here are the entities and their states and it’s been working great.

This is my complete working code for everyone searching for the same issue:

binary_sensor:
- platform: template
  sensors:
    hmipanwesenheit:
      value_template: '{{ states.homematic.raspberrymatic.attributes.Anwesenheit == true }}'
      entity_id: homematic.raspberrymatic
      friendly_name: 'Anwesenheit'
    hmipanwesenheitandreas:
      value_template: '{{ is_state_attr("homematic.raspberrymatic", "Anwesenheit Andreas", true) }}'
      entity_id: homematic.raspberrymatic
      friendly_name: 'Anwesenheit Andreas'
    hmipanwesenheitstefanie:
      value_template: '{{ is_state_attr("homematic.raspberrymatic", "Anwesenheit Stefanie", true) }}'
      entity_id: homematic.raspberrymatic
      friendly_name: 'Anwesenheit Stefanie'

Cheers

Andreas

1 Like