Automation Not Working (Yeelight YLKG07YL dimmer)

Hello everyone!

I just started with the Home Assistant, and i am having some trouble on getting this automation working.

I want to make some automations that:
1- With a single press i can toggle on/off my light.
2- Rotating right, i want to increase the light’s brightness, based on steps rotated.
3- Rotating left, i want to decrease the light’s brightness, based on steps rotated.
4- Rotate (pressing) right, i want to increase the light’s temperature, based on steps rotated.
5- Rotate (pressing) left, i want to decrease the light’s temperature, based on steps rotated.

As mentioned, i am fairly new to the HA world, and i’m already having some issues with the first one hahaha

this is the automation.yaml for the # 1, that does not work:

- id: '1634841412504'
  alias: Dimmer e Luminária
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.ble_dimmer_dimmer
    attribute: last type of press
    to: short press
  condition: []
  action:
  - type: toggle
    device_id: 95e57c60dfca42d55577c7e968b777fc
    entity_id: light.luminaria
    domain: light
  mode: single

I am sure that the attribute’s stat is right, as i just confirmed on my devices, on the sensor’s attributes:

sensor type: YLKG07YL/YLKG08YL
mac address: xxxxxx #MAC is ok
last packet id: 108
firmware: Xiaomi (MiBeacon V3 encrypted)
dimmer value: 1
last type of press: short press
rssi: -59
friendly_name: Estado Dimmer
icon: mdi:rotate-right

and also, with the integration’s documentations, the “last type of press” can receive the respective values:
1- short press
2- long press
3- rotate right
4- rotate left
5- rotate right (pressed)
6- rotate right (pressed)

and the “dimmer value” refers to the steps (when rotating) or the time pressed in seconds (long press).
if nothing is pressent, the entity sensor.ble_dimmer_dimmer resets to “no press” after one second.

Can someone help with what i am doing wrong, and how can i structure the following automations with this infos?

Thanks in advance!

maybe this helps

- id: "123456789"
  alias: "toggle light"
  trigger:
    platform: state
    entity_id: sensor.ble_dimmer_f82441c8a3a2
    attribute: last packet id
  condition:
    condition: template
    value_template: "{{ state_attr('sensor.ble_dimmer_f82441c8a3a2', 'last type of press') == 'short press'}}"
  action:
    - service: light.toggle
      target:
        entity_id: light.dimmer_virtual
    #- service: system_log.write
    #  data_template:
    #    message: "{{ state_attr('sensor.ble_dimmer_f82441c8a3a2', 'last packet id') }} {{ state_attr('sensor.ble_dimmer_f82441c8a3a2', 'last type of press') }}"
- id: "223456789"
  alias: "set brightness up"
  trigger:
    platform: state
    entity_id: sensor.ble_dimmer_f82441c8a3a2
    attribute: last packet id
  condition:
    condition: template
    value_template: "{{ state_attr('sensor.ble_dimmer_f82441c8a3a2', 'last type of press') == 'rotate right'}}"
  action:
    - service: light.turn_on
      target:
        entity_id: light.dimmer_virtual
      data:
        brightness: "{{states.light.dimmer_virtual.attributes.brightness + (state_attr('sensor.ble_dimmer_f82441c8a3a2', 'dimmer value') *4) }}"
#    - service: system_log.write
#      data_template:
#        message: "{{ state_attr('sensor.ble_dimmer_f82441c8a3a2', 'dimmer value') }}"
- id: "323456789"
  alias: "set brightness down"
  trigger:
    platform: state
    entity_id: sensor.ble_dimmer_f82441c8a3a2
    attribute: last packet id
  condition:
    condition: template
    value_template: "{{ state_attr('sensor.ble_dimmer_f82441c8a3a2', 'last type of press') == 'rotate left'}}"
  action:
    - service: light.turn_on
      target:
        entity_id: light.dimmer_virtual
      data:
        brightness: "{{states.light.dimmer_virtual.attributes.brightness - (state_attr('sensor.ble_dimmer_f82441c8a3a2', 'dimmer value') *4) }}"

2 Likes

Hi! Im having the same problem. Did you find any solotuions?

How do you even integrate it? Passive BLE Monitor? I’m only getting RSSI strenght, even with seemingly proper bind_key