Help setting up the YLKG07YL, YLKG08YL dimmer switches

Hello! I would like to get some help :sunny:

I’m sorry, could you explain where should I put this?: (When I try to the entities card: I can’t save it. Or this one is goes too in the configuration.yaml?)

alias: ble dimmer automation
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.ble_dimmer_dimmer_yeelight
    attribute: last_packet_id
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.ble_dimmer_dimmer_yeelight
            attribute: last_type_of_press
            state: short press
        sequence:
          - service: light.toggle
            data: {}
            target:
              entity_id: light.yeelink_ceiling5_41d0_light
      - conditions:
          - condition: state
            entity_id: sensor.ble_dimmer_dimmer_yeelight
            attribute: last_type_of_press
            state: rotate right
        sequence:
          - service: light.turn_on
            data:
              brightness_step_pct: >-
                {{ state_attr('sensor.ble_dimmer_dimmer_yeelight',
                'dimmer_value') | int*5 }}
            target:
              entity_id: light.yeelink_ceiling5_41d0_light
      - conditions:
          - condition: state
            entity_id: sensor.ble_dimmer_dimmer_yeelight
            attribute: last_type_of_press
            state: rotate left
        sequence:
          - service: light.turn_on
            data:
              brightness_step_pct: >-
                {{ state_attr('sensor.ble_dimmer_dimmer_yeelight',
                'dimmer_value') | int*-5 }}
            target:
              entity_id: light.yeelink_ceiling5_41d0_light
mode: single

I changed the entity names for my setup.



Go to Settings → automations → “create automation” → “create new automation”, now on the top right, you see the 3 dots, click those → edit in Yaml → paste my code there, hit save.

Now go back to “automations” and you should see a new automation there.
Click on it, and you can either use the visual editor, or the Yaml to edit it.

For adding the ble device, I added it to my configuration.yaml (file editor → /config/configuration.yaml)

How fast does the battery drain for you guys?

Same here. Only RSSI and no sensors. Have you been successful yet?

Hello everyone,

I post here because lot of people having trouble with their YLKG07YL dimmer, and I was like you, been nuts to have beacon_key or adding it in home assistant… take me hours of digging to fix it !

Here what i’ve test, done, and check :slight_smile:

First of all, recover the MAC adresse of the device with phone app for me “A4:C1:38:35:4F:62”

Be carefull, pressing the pariring button during 20s will change this MAC address

After that use the method 5 from Passive BLE integration FAQ :

5. get_beacon_key python script

In my case :

wget https://raw.githubusercontent.com/custom-components/ble_monitor/master/custom_components/ble_monitor/ble_parser/get_beacon_key.py
apt-get install python3-pip libglib2.0-dev
pip3 install bleak asyncio
python3 get_beacon_key.py <A4:C1:38:35:4F:62> <950>

Be sure to use a relevant linux, bluetooth and python configuration

If you can’t connect to your device or if it’s say “Disconnected!”, try this before launching the script :

hciconfig hci0 up

After that you will have something like this :

notifyData: ‘ce6b3f6f42adc97421cf015f’
cipheredRes: ‘00a486f5ff013ed04322f4e4’
randomToken: ‘00a486f5ff013ed04322f4e4’
Successful authentication!
beaconKey: ‘acec46f9b751b694e8167d02’
firmware_version: '2.0.0_0004

Now you have you beacon_key, you can configure the BLE device to HASS on configuration.yaml

But cherry on the cake you have to add eight f to the end of the encryption_key

ble_monitor:
  discovery: true
  devices:
    - mac: 'A4:C1:38:35:4F:62'
      name: 'dimmer_yeelight'
      encryption_key: 'acec46f9b751b694e8167d02ffffffff'
      reset_timer: 1

Hope it will help ! Thanks to [frickeo]

1 Like

Have you come across any BLE switches or dimmers that work well with ESPHome?

hi, I didn’t understand how to get the beacon key?

Hi, I’ve been working on making this work and tried everything, but cannot get the beacon key.

imagen

anyone has the same error as me? Thanks in advance!

The previous automations written here did not work for me because my dimmer also sends the number of clicks in the rotation events.

Therefore, I modified the automation as follows:

alias: Yeelight dimmer
triggers:
  - entity_id:
      - sensor.ble_dimmer_dimmer_yeelight
    attribute: last_packet_id
    trigger: state
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: sensor.ble_dimmer_dimmer_yeelight
            state: short press 1 steps
        sequence:
          - data: {}
            action: light.toggle
            target:
              entity_id: light.yeelink_mono5_117c_switch_status
      - conditions:
          - condition: template
            value_template: >
              {{ states('sensor.ble_dimmer_dimmer_yeelight') |
              regex_match("rotate right \d+ steps") }}
        sequence:
          - action: light.turn_on
            data:
              brightness_step_pct: >
                {{ (states('sensor.ble_dimmer_dimmer_yeelight') |
                regex_findall_index("\d+")) | int * 2 }}
            target:
              entity_id: light.yeelink_mono5_117c_switch_status
      - conditions:
          - condition: template
            value_template: >
              {{ states('sensor.ble_dimmer_dimmer_yeelight') |
              regex_match("rotate left \d+ steps") }}
        sequence:
          - action: light.turn_on
            data:
              brightness_step_pct: >
                {{ (states('sensor.ble_dimmer_dimmer_yeelight') |
                regex_findall_index("\d+")) | int * -2 }}
            target:
              entity_id: light.yeelink_mono5_117c_switch_status
mode: single