Aqara wall switch to control lights

I’ve made a script I want to share, to control the lights using a wall switch.
The switch is a aqara zigbee wall switch that is connected with Zigbee2MQTT. The lights are an Ikea Tradfri bulb (also Zigbee2MQTT) and a light with a sonoff. The button can detect long presses and double presses, this allows to control brightness and color of the light with a single button, but only if the light supports it.


- id: '1552853418090'
  alias: SlaapkamerLampknop
  - entity_id: sensor.slaapkamerlampknop
    platform: state
  condition: []
  - data_template:
      button: '{{ trigger.to_state.state}}'
      entity: '{{ trigger.to_state.entity_id}}' 
    service: python_script.slaapkamerlampknop

python script:

#compare color
def compare_color(color1,color2):
    return (-5 <= (color1[0]-color2[0]) <= 5 and -5 <= (color1[1]-color2[1]) <= 5 and -5 <= (color1[2]-color2[2]) <= 5)
#get state and entity_id of button from automation
buttonState = data.get('button')
buttonEntity = data.get('entity')

#get target light based on trigger device and button
if buttonEntity == 'sensor.slaapkamerlampknop' and buttonState.startswith('left'):
    entity_id = 'light.myfirstbulb'
elif buttonEntity == 'sensor.slaapkamerlampknop' and buttonState.startswith('right'):
    entity_id = 'light.nachtkastlamp'
    entity_id = ''
if entity_id != '':
    #find out which features are supported by the target light
    light = hass.states.get(entity_id)
    features = light.attributes.get('supported_features')
    if buttonState.endswith('long') and features % 2 >= 1:
        #change brightness on long button press
        service = 'turn_on'
        brightness = light.attributes.get('brightness') or 0
        if brightness < 150:
            service_data = {'entity_id': entity_id, 'brightness': 200}
            service_data = {'entity_id': entity_id, 'brightness': 100}
    elif buttonState.endswith('double') and features % 32 >= 16:
        #change color on double press
        service = 'turn_on'
        rgb = light.attributes.get('rgb_color') or [0,0,0]
        colors = {
        if compare_color(rgb,colors["white"]):
            service_data = {'entity_id': entity_id, 'rgb_color': colors["yellow"]}
        elif compare_color(rgb,colors["yellow"]):
            service_data = {'entity_id': entity_id, 'rgb_color': colors["orange"]}
        elif compare_color(rgb,colors["orange"]):
            service_data = {'entity_id': entity_id, 'rgb_color': colors["red"]}
        elif compare_color(rgb,colors["red"]):
            service_data = {'entity_id': entity_id, 'rgb_color': colors["white"]}
            service_data = {'entity_id': entity_id, 'rgb_color': colors["yellow"]}
        service = 'toggle'
        service_data = {'entity_id': entity_id}
 'light', service, service_data, False)

Hello i am planning to buy also the Aqara wall switch. Should be that works with conbee 2 with the same setup as of you?