How to force integer value for homematic.set_device_value

Hi,

i’m trying to create an automation to change the ACTIVE_PROFILE for a Homematic IP Thermostat, but it doesn’t work, because it seems to use the value parameter as a string and not as an integer which is expected by the CCU XmlRPC.

If I try the Service under Developer Tools with following JSON, it works perfectly:

{
    "address": "INT0000001",
    "channel": 1,
    "param": "ACTIVE_PROFILE",
    "interface": "groups",
    "value": 1
}

This is the automation which i’m trying to execute.

- alias: ChangeGroupProfile
  trigger:
    - platform: time
      at: '00:05:05'
  action:
    - service: homematic.set_device_value
      data_template:
        address: 'INT0000001'
        channel: 1
        param: 'ACTIVE_PROFILE'
        interface: groups
        value: >
          {% if ((states('sensor.week_number')|default(0)|int) % 2) == 0 %}
          1
          {% else %}
          2
          {% endif %}

I have tried using as value only 1 or {{ ‘1’|int }}, nothing worked. In the log file, if I execute the Service using Developer Tools or through automation I always see the same, so no difference is recognisable:

DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L] domain=homematic, service=set_device_value, service_data=address=INT0000001, channel=1, param=ACTIVE_PROFILE, interface=groups, value=1>
DEBUG (SyncWorker_10) [pyhomematic.devicetypes.generic] HMGeneric.setValue: address = 'INT0000001:1', key = 'ACTIVE_PROFILE' value = '1'

Is there any way to force that value becomes an integer?

Unfortunately this was not possible with the current implementation. I just submitted a Pull Request were value_type is being introduced, to force the desired data type for value.

- alias: ChangeGroupProfile
  trigger:
    - platform: time
      at: '00:05:05'
  action:
    - service: homematic.set_device_value
      data_template:
        address: 'INT0000001'
        channel: 1
        param: 'ACTIVE_PROFILE'
        interface: groups
        value_type: 'int'
        value: >
          {% if ((states('sensor.week_number')|default(0)|int) % 2) == 0 %}
          1
          {% else %}
          2
          {% endif %}

Is it possible to set all displayed numbers as integers?

Decimal places are preventing other info from being presented in portrait view in the HA Android app.