Light control of IHC / LK 2 or 4-button wall switch

Edit: Updated 1-1-2022
Description:
Simple blueprint that accepts 2 binary sensor inputs to control a light.

Inputs:
Binary Sensor On - Binary sensor that is used to for turning On, and holding “On” state will increase brightness

Binary Sensor Off - Binary sensor that is used to for turning Off, and holding “On” state will decrease brightness

Hold threshold - Time to consider binary sensor input is being held, instead of just pushed.

Brightness step - Percentage brightness increase/decrease in each transition step.

Brightness step delay - Length of delay between each brightness step.

Default Brightness - Default brightness that light will turn on with.

Output:
Target Light - Whatever light you wish to control that can be dimmed via brightness.

Blueprint Code
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Light controller
  description: Turn a light On/Off/Up/Down based on binary sensor
  domain: automation
  input:
    light_turn_on:
      name: Binary Sensor On
      description: This sensor is used to register turn On state
      selector:
        entity:
          domain: binary_sensor
    light_turn_off:
      name: Binary Sensor Off
      description: This sensor is used to register turn Off state
      selector:
        entity:
          domain: binary_sensor
    target_light:
      name: Light
      selector:
        entity:
          domain: light
    hold_threshold:
      name: Hold threshold
      description: Time to consider binary sensor input is being held, instead of just pushed.
      default: "0.8"
      selector:
        number:
          min: "0.05"
          max: "10"
          step: "0.05"
          unit_of_measurement: s
    brightness_step_pct:
      name: Brightness step
      description: Percentage brightness increase/decrease in each transition step.
      default: "10"
      selector:
        number:
          min: "1"
          max: "100"
          unit_of_measurement: "%"
    delay_steps:
      name: Brightness step delay
      description: Length of delay between each brightness step.
      default: "0.3"
      selector:
        number:
          min: "0"
          max: "5"
          step: "0.01"
          unit_of_measurement: s
    default_brightness:
      name: Default Brightness
      default: 190
      selector:
        number:
          min: 1
          max: 255
          mode: slider

# Trigger when binary_sensor is changed from Off to On
trigger:
  - platform: state
    entity_id: 
      - !input light_turn_on
      - !input light_turn_off
    to: 'on'
condition: []

# Declare blueprint inputs as variables for use in {{templates}}  
variables:
  light_turn_on: !input light_turn_on
  light_turn_off: !input light_turn_off
  target_light: !input target_light
  brightness_step_pct_positive: !input brightness_step_pct
  brightness_step_pct_negative: "{{ brightness_step_pct_positive|int * -1 }}"

action:
  - wait_for_trigger:
      - platform: state
        entity_id: !input light_turn_on
        id: turn_on
        to: "off"
        from: "on"
      - platform: state
        entity_id: !input light_turn_off
        id: turn_off
        to: "off"
        from: "on"
    timeout: !input hold_threshold
    continue_on_timeout: true
  - choose:
      - conditions:
        - condition: template
          value_template: '{{ wait.trigger.id == "turn_on" }}'
        sequence:
        - service: light.turn_on
          entity_id: !input target_light
          data:
            brightness: !input default_brightness
      - conditions:
        - condition: template
          value_template: '{{ wait.trigger.id == "turn_off" }}'
        sequence:
        - service: light.turn_off
          entity_id: !input target_light
      - conditions:
        - condition: template
          value_template: '{{ ( trigger.entity_id ) == ( light_turn_on ) and wait.trigger == none }}'
        sequence:
          repeat:
            while:
              - condition: state
                entity_id: !input light_turn_on
                state: "on"
            sequence:
              - service: light.turn_on
                data:
                  brightness_step_pct: "{{ brightness_step_pct_positive }}"
                entity_id: !input target_light
              - delay:
                  seconds: !input delay_steps
      - conditions:
        - condition: template
          value_template: '{{ ( trigger.entity_id ) == ( light_turn_off ) and wait.trigger == none }}'
        sequence:
          repeat:
            while:
              - condition: state
                entity_id: !input light_turn_off
                state: "on"
            sequence:
              - service: light.turn_on
                data:
                  brightness_step_pct: "{{ brightness_step_pct_negative }}"
                entity_id: !input target_light
              - delay:
                  seconds: !input delay_steps

Extra IHC / LK information:
I use this automation with my ICH wireless 2 or 4-button wall switch.

How to setup binary sensor in configuration.yaml:

image

Hold CTRL down and the point on “Tryk (Øverst venstre)” and “Tryk (Øverst højre)”, to get ID numbers for your IHC setup in the configuration.yaml.
image
image

1 Like

Hey i can’t inport you blue blueprint and the IHC blok you a refering to

I think you can just create a file called what_ever_you_want.yaml and then copy my blueprint in there.

However do you have an IHC controller, because you need that to use it with IHC.

Edit.

I have updated the blueprint to make it easier with the IHC ingration.

I can’t import your code, either blueprint or the other way

What is the issue because it working fine here.

No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.

i can not save it under yamel. it reports errors. do you have a picture as an example?

What do you mean by a picture?

I have added the yaml tag and the blueprint link, but I cant get that to work.

Should work now

Have you changed anything? can I download it now ???
thank you. good work

I removed the ihc configuration that I put in block code, I can import it now without errors. Cant tget he link to work.

Is it working now for you?

Yes, it works for me now.

Is it possible to make this for output to simpel switches instead ?

Yeah I think that is possible, but I assume that you would not need the dimming part of the blueprint?

Correct - just to use one binary (Switch OH (upper right) to change state of a switch a shelly relay

Yeah that can be done. I have another blueprint I use to control my Ikea fyrtur blinds.

However if you just need it for one relay, then it should be a pretty simple automation.

 alias: ihc switch
  trigger:
  - platform: state
    entity_id: binary_sensor.your_sensor_name
    from: 'Off'
    to: 'on'
  condition: []
  action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.your_switch_name

It needs to turn off the switch when pressed and turn it on when pushed again …

Kip funktion in danish …

The script couldnt be pasted - required key not provided

You could add a small delay and then switch off again.

alias: ihc switch
  trigger:
  - platform: state
    entity_id: binary_sensor.your_sensor_name
    from: 'off'
    to: 'on'
  condition: []
  action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.your_switch_name
  - delay:
      milliseconds: 500
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.your_switch_name

When i put this in as a new automation i get this :

Message malformed: required key not provided @ data[‘trigger’]

It could also just be a “toggel”

Hi,
Is it possible to use 1 button for both on and off?
/Claus