Philips Hue, Friends of Hue switch 4 buttons for Hue Integration

Actually it works very well with the last edit I did in my post #58

I wanted to create a separate blueprint as complement for the one you wrote, to make the script faster to implement, but was able to do only the first part with user input the action part cannot understand how to make it work … below my try. If I will succeed will edit this post and correct it.

blueprint:
  name: Single/Double Tap
  description: Perform actions based on single or double tap (based on counter
  domain: script
  input:
    counter_entity:
      name: Counter Entity
      description: The entity_id of the counter.
      selector:
        entity:
          domain: counter
    single_tap_delay:
      name: Single Tap Delay (milliseconds)
      description: Delay in milliseconds after a single tap.
      default: 400
      selector:
        number:
          min: 0
          max: 1000
          unit_of_measurement: milliseconds
    single_tap_action:
      name: Single Tap Action
      description: Action to perform on a single tap.
      selector:
        action:
    double_tap_action:
      name: Double Tap Action
      description: Action to perform on a double tap.
      selector:
        action:

mode: restart
max_exceeded: silent

---NOT WORKING---
script:
  alias: Single/Double Tap
  sequence:
    - service: counter.increment
      target:
        entity_id: !input counter_entity
    - if:
        - condition: state
          entity_id: !input counter_entity
          state: "1"
      then:
        - delay:
            milliseconds: !input single_tap_delay
        - sequence: !input single_tap_action
        - service: counter.reset
          target:
            entity_id: !input counter_entity
      else:
        - if:
            - condition: state
              entity_id: !input counter_entity
              state: "2"
          then:
        - sequence: !input double_tap_action
        - service: counter.reset
          target:
            entity_id: !input counter_entity

Hi,

I read some people suggested the Switch 1+3 and 2+4 simultaneously pressing function. What I can’t find out.
Is it working now? At the moment I’m using this feature with the hueessentials Android app, but I would like to Switch the logic into homeassistant

Unfortunately the 1+3 button is not relayed by the hue integration into HA, so there is never an event. Hence, it will not be possible.

thanks for your reply.

Do you plan to add your blue print as blue print addable via git?

Hi Stephan, Not sure how to do this and I do not use github for anything else.

You are very welcome to create it, making it easier for everybody else. I will not object at all.

I will continue to update the blueprint if changes are needed due to HA changes, and post new versions in this thread.

Maybe another developer can help you?
I think this have to be done by the creator of the blueprint.
It’s this with the Add to Homeassistant button here in the blueprint section.
Sadly I have no experience in creating such things

Hi
I created a Blueprint link, it’s a direct copy of post #32, let me know if you want credits or licenses added
Friends Of Hue switch, 4 button, all functions Blueprint

Perfekt, making it easier for everybody else.

Hi,
I developed an enhancement based on the blueprint post#32 with the goal to provide support for multiple (currently 4) button taps in a sequence with dedicated actions for short release and long release.

See the blueprint on GitHub Gist:
Home Assistant - Blueprint: Hue, Friends Of Hue switch, 4 button, supports up to 4 taps in a sequence with dedicated actions to short and long release

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

All assigned actions will be performed for each tap in a sequence except for “initial press” which will be performed at the first tap in a sequence only. This follows the original Philips Hue FoH execution logic.

Thus you can setup for each button and separately for “short release” and “long release” up to 4 actions assigned to respective “taps” in a button press / release sequence. Although the blueprint can easily be extend to more than 4 taps this is not recommended as the usability deteriorates and the probability for sync errors increases.

Unfortunately the Hue API event sequence is quite complex which requires for this blueprint 3 counter helpers to be created. For the specification see the comments in the blueprint code header.

Testing showed that synchronization for the parallel running instances, which are triggered by each event a button press and release causes, is sensitive to the required delay before executing the actions. The default value of 1,500 ms should work for most situations, but depending on your hardware, software or button press frequency it may need to be adjusted on the UI config page or right away in the automation code.

Please note - that the actions are performed exactly in order as they happen on the FoH switch. Therefore a sequence of:
( Tap 1) initial press - short release / (Tap 2) initial press - repeat - repeat (- short release) - long release / (Tap 3) initial press - short release

will perform the following:
(Tap 1) initial press action and subsequently short release action tor Tap 1
(Tap 2) repeat action, repeat action and long release action for Tap 2
(Tap 3) short release action for Tap 3

Takeaways:

  • the initial action is performed for Tap 1 only
  • short release actions are performed for Tap 1 and Tap 3
  • long release action is performed for Tap 2 only
  • for a long button hold and release the Hue API may generate (not always !) an additional short release event which is omitted and the long release action is carried out only

Home Assistant can respond to FoH switch (button press/release) events in addition to the Hue Bridge itself. Thus there may be running automations on HA and Hue bridge in parallel. This may be helpful to fill functionality gaps of the Hue bridge, e. g. it can be used to carry out actions regarded to several Hue bridges as turn off all lights in the house on various Hue bridges and switch off AV and TV etc.
Unfortunately the Hue bridge timing to distinguish between short and long release is different (shorter) than for the Hue API. Thus there are button press - release timings which are seen by the Hue bridge already as a “long release” whereas the Hue API shows a “short release” only. Therefore it is not possible to synchronize short and long releases of the Hue bridge and in HA correctly.

For code reviews please note

  • there are rare cases in which for a de facto long pressed button just a single repeat and following short release event is shown without corresponding long release event - this is handled appropriate as well
  • for very long pressed buttons (e. g. with more than 15 repeats) the Hue API does not show a short release event anymore but just the final long release event. All this situations are managed by the blueprint.

Regarding code of post #32 let me know if you want credits or licenses added

1 Like

Hi, have changed the text in post one. Do you know how to make a “import blueprint” blue button. If you know, I will include one in the initial post, pointing to your github, making it much easier for others.

I have created an automation that uses this blueprint. However, when I press a button on the switch nothing happens. I see in the log file that the button is pressed. what am I doing wrong?

The intention is

Press button 3 once, lamp on
Press button 4 once, lamp off

Keep button 3 pressed to make the lamp brighter
Press and hold button 4 to dim the lamp

the lamp is an idea lamp called “storage tmp”

alias: Schakelaar berging buitendeur
description: ""
use_blueprint:
  path: Anybody4u/foh_mutiple_tap_v2.yaml
  input:
    hue-switch-button1:
      - event.friends_of_hue_switch_1_button_1
    hue-switch-button2:
      - event.friends_of_hue_switch_1_button_2
    hue-switch-button3:
      - event.friends_of_hue_switch_1_button_3
    hue-switch-button4:
      - event.friends_of_hue_switch_1_button_4
    button_press_B1: []
    button_press_B2: []
    button_press_B3:
      - service: light.turn_on
        metadata: {}
        data:
          brightness_pct: 100
        target:
          device_id: a32403ed3f14e0d129bbc8e63b973476
          entity_id: light.lightbulb
    button_press_B4:
      - service: light.turn_off
        target:
          entity_id: light.lightbulb
        data: {}
    button_short_release_B1-3: []
    button_long_release_B1-3: []

Which version of the blueprint are you using.

Be aware that the press is initial press, hence will trigger even if you hold the button pressed.

The lastone whit the blue button from post 68

alias: Hue, Friends Of Hue switch, 4 button, multi tap v2

blueprint:
  name: Hue, Friends Of Hue switch, 4 button, multi tap v2
  description: >
    HA version 2023.08 or newer.
    Works with all Hue API functions and 
    supports up to 4 taps in a sequence with dedicated actions to short and long release
    Correct the problem of "short release" triggered on the same time as "long release"
    If multiple switches needing the same functionality, select multiple switches per button.
#===============================================================================
#=====  This blueprint requires the following 3 helper-counters
#=====    name:          foh_run_counter
#=====                   foh_initial_press_counter
#=====                   foh_long_release_counter
#=====  all with the following configuration
#=====    minimum vlaue: 0
#=====    initial value: 0
#=====    step size    : 1 
#=====    Restore the last known value when Home Assistant starts: OFF
#=====  
#=====  To create helpers go to: Settings -> Devices&Services -> Tab: Helpers
#=====  Press button [Create Helper] -> choose "Counter" -> Set config -> Save
#===============================================================================
#=====  Based on
#=====  https://community.home-assistant.io/t/philips-hue-friends-of-hue-switch-4-buttons-for-hue-integration/499450/32
#===============================================================================

i get this error in the logfile:

Logger: homeassistant.components.automation.schakelaar_berging_kantoordeur
Bron: components/automation/__init__.py:687
integratie: Automatisering (documentation, issues)
First occurred: 00:37:55 (2 gebeurtenissen)
Laatst gelogd: 00:37:56

Error while executing automation automation.schakelaar_berging_kantoordeur: ValueError: Template error: int got invalid input 'unknown' when rendering template '{{ int(states('counter.foh_run_counter'))|d(1) }}' but no default was specified

I can turn the light on and off now :slight_smile:

must make some helpers

===============================================================================
#=====  This blueprint requires the following 3 helper-counters
#=====    name:          foh_run_counter
#=====                   foh_initial_press_counter
#=====                   foh_long_release_counter
#=====  all with the following configuration
#=====    minimum vlaue: 0
#=====    initial value: 0
#=====    step size    : 1 
#=====    Restore the last known value when Home Assistant starts: OFF
#=====  
#=====  To create helpers go to: Settings -> Devices&Services -> Tab: Helpers
#=====  Press button [Create Helper] -> choose "Counter" -> Set config -> Save
#===============================================================================

Some problems, i have more of these switches in my hue configuration. Is this possible whit Home assistant

This is working:

Press button 3 once, lamp on
Press button 4 once, lamp off

Keep button 3 pressed to make the lamp brighter

This is not:
Press and hold button 4 to dim the lamp (It now is turning the light off)

Ok. Not sure about this version of the blueprint, a more advanced version with a lot of possibilities and needing helpers.
The version from post 32 is my latest. That version is also the one referenced in the original post as I have updated (in post 1)

thnx khveh! I installed your version, it seems it is allot faster. I use the version from post 32 now. confusing 2 versions in 1 message :wink:

is there an time for short release, long release, press and repeat (repeat is holding it in i think?)

Behaviour

  • “Press” is when you press the button, it will trigger immediately and always
  • “short release” is when you release after a short time (will happen it you release the button before the first “repeat”)
  • “repeat” will trigger app 2 times a second while holding down. first one app. after 1,5 sec
  • “long release” will trigger when you release after a long press. Will happen if there have been a “repeat”

As I read your usecase:

  • Use “short release” for on/off
  • Use “repeat” for dim+/dim-

Regarding versions. The version I maintain is in post 1. Currently version in post 32 and post 1 is the same.

1 Like

How to get rid of the button setup in the HUE app and still keep the switch in HUE and there by in HA …?

when i connect the switch to HUE i have to make an entry on short press- on the long one i have an opportunity to chose “do nothing” this one i don´t have in short press…
Hope it makes sence :slight_smile:

Not sure how, did it a long time ago.

I have switches with no actions in the HUE app. In the hue app it says “not configured in this app”.

Hmm tried to send it to apple home for config there. But that gives me a new problem Friends of HUE cant be controlled without Apple HUB…