Priority Switch for KNX integration DPT 2.001

Hi, I want to integrate a special (priority) switch into HA. It’s called priority switch and used to override the current switch state with a second switch where I can set the priority. So, If I enable the priority bit, I can control the switch regardless which state the switch has. A definition from KNX is:

The Switch Control is used to operate actuators – next to the normal operation via the Switch – by a group object with higher priority. The switching function of a connected device depends on the state of the two group objects Switch and Switch Control. The group object of type Switch Control has a size of 2 bits. If the value of the 2 bit object is 0 or 1, the connected actuator is controlled via the switching object. If the value of the priority object is 2, the output is switched off respectively on when the value is 3. The value of the switching object is in both cases ignored.

Within KNX integration I already started the implementation and it’s working with the values 0,1,2,3 to control my heating actor. Now, I’m not sure how to add this behaviour to HA? First idea was a sensor, but a sensor is more to just get values and not for sending values. So it would be a switch which can send 3 states. To control it from the UI we could use an input_select with the 3 or 4 states and then trigger an automation. But within the automation, which kind of integration we would use? Or creating an own type of input_select or input_number for platform knx? Any idea who we could integrate this new component to HA?

1 Like

Dear Michel,
I just found a workaround for this and it works fine for me!
I’m using a switch template which sends custom payload to Knx bus, on his turn_on/off states:

switch:

  • platform: template
    switches:
    forz:
    value_template: “{{ is_state(‘sensor.forz’, ‘on’) }}”
    turn_on:
    service: knx.send
    data:
    address: “1/0/19”
    payload: ‘3’
    turn_off:
    service: knx.send
    data:
    address: “1/0/19”
    payload: ‘0’

Then in the automation i’m simply calling the service switch.turn_on/off depending on the logic.
In the payload example above I’m sending:

  • 00 (payload 0) to cancel the prioriry
  • 11 (payload 3) to switch on the priority

Hope this will work fine for you too! :slight_smile:
Let me know,
Simone

Hi Simone,

thanks for sharing your solution. Can you tell me how you have defined your sensor which you’re referring to in the template switch?

Thanks,
Michel

I wanted to share my current implementation as I now have some more experience with Home Assistant.

  1. created an input select option:
input_select:
  wartung_ventile:
    name: Servicebetrieb Ventile
    options:
      - Alle aus
      - 0 - 2/0/4 - KG Servicebetrieb nicht aktiv
      - 2 - 2/0/4 - KG Servicebetrieb aktiv Ventile schließen
      - 3 - 2/0/4 - KG Servicebetrieb aktiv Ventile öffnen
    initial: Alle aus

Then I created an automation, which takes the payload from the option and also the knx address:

- id: '1618594593970'
  alias: Heizung Servicebetrieb Ventile
  description: ''
  trigger:
  - platform: state
    entity_id: input_select.wartung_ventile
  condition: []
  action:
  - service: knx.send
    data:
      address: '{{ states(''input_select.wartung_ventile'')[3:9] }}'
      payload: '{{ states(''input_select.wartung_ventile'')[:1] }}'
  mode: single
1 Like

Thank you for that nice blue print – I am using this to control some lights with HASS in a smarter way (i. e. fade in/out)

This works well for me, however, the input_select state is reverted to its initial value every day around midnight what seems to be somehow akward since there is neither a log entry nor an automation trace at that time.