ZHA - Sengled Smart Light Switch (E1E-G7F) with complete control of every button

Tags: #<Tag:0x00007fc40930a280> #<Tag:0x00007fc40930a168> #<Tag:0x00007fc40930a050> #<Tag:0x00007fc409309f10>

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

This blueprint offers complete control every button on the Sengled E1E-G7F Smart Switch using the ZHA integration. Thank you to @compeek for building this zha device handler.

Picture of the remote. Check to confirm you have this one.

If you are looking for a really easy Blueprint to make this a simple light switch remote check out this Blueprint by @ppyrrhula at ZHA - Sengled Smart Light Switch (E1E-G7F)

If you want to customize each button and button option then this is your Blueprint.

Button options include:

  • On short press
  • On long press
  • On double press
  • Off short press
  • Off long press
  • Off double press
  • Brighten short press
  • Brighten long press (or press and hold)
  • Dim short press
  • Dim long press (or press and hold)


Why

I wanted to be able to customize every button press and option myself. Most of the buttons will do just like you’d expect, to improve WAF (wife approval factor). But, I also wanted the option to have a ‘hidden feature’ or something like that. For example, off long press will trigger my home security alarm. This way if my wife wants to carry the remote around to make her feel more safe she can trigger the alarm like a panic button.

Blueprint

Pre-requisite: You must be on HA Core version >= 2021.2.1 or install updated device handlers manually to have this Sengled E1E-G7F device supported

blueprint:
  name: 'Sengled Smart Light Switch (Model: E1E-G7F) ZHA'
  description: Use your Sengled E1E-G7F four button zigbee remote on ZHA.
  domain: automation
  input:
    remote:
      name: Sengled Smart Light Switch
      description: 'Sengled Smart Light Switch (Model: E1E-G7F)'
      selector:
        device:
          integration: zha
          manufacturer: sengled
          model: E1E-G7F
    on_short_press:
      name: On Button Short Press
      description: 'Actions to run when you do a short press of the "on" button.'
      default: []
      selector:
        action: {}
    on_long_press:
      name: On Button Long Press
      description: 'Actions to run when you do a press and hold the "on" button.'
      default: []
      selector:
        action: {}
    on_double_press:
      name: On Button Double Press
      description: 'Actions to run when you do a quick double press of the "on" button.'
      default: []
      selector:
        action: {}
    off_short_press:
      name: Off Button Short Press
      description: 'Actions to run when you do a short press of the "off" button.'
      default: []
      selector:
        action: {}
    off_long_press:
      name: Off Button Long Press
      description: 'Actions to run when you do a press and hold the "off" button.'
      default: []
      selector:
        action: {}
    off_double_press:
      name: Off Button Double Press
      description: 'Actions to run when you do a quick double press of the "off" button.'
      default: []
      selector:
        action: {}
    up_short_press:
      name: Up Button Short Press
      description: 'Actions to run when you do a short press of the "up" or "brighten" button.'
      default: []
      selector:
        action: {}
    up_long_press:
      name: Up Button Long Press
      description: 'Actions to run when you do a long press of the "up" or "brighten" button. When you press and hold the remote always sends a single press then the following will be "long" press until you release. This could be used to increment in larger steps.'
      default: []
      selector:
        action: {}
    down_short_press:
      name: Down Button Short Press
      description: 'Actions to run when you do a short press of the "down" or "dim" button.'
      default: []
      selector:
        action: {}
    down_long_press:
      name: Down Button Long Press
      description: 'Actions to run when you do a long press of the "down" or "dim" button. When you press and hold the remote always sends a single press then the following will be "long" press until you release. This could be used to increment in larger steps.'
      default: []
      selector:
        action: {}
mode: parallel
max_exceeded: silent
trigger:
- platform: event
  event_type: zha_event
  event_data:
    device_id: !input 'remote'
action:
- variables:
    command: '{{ trigger.event.data.command }}'
    value: '{{ trigger.event.data.args }}'
- choose:
  - conditions:
    - '{{ command == ''on'' }}'
    sequence: !input 'on_short_press'
  - conditions:
    - '{{ command ==  ''on_double'' }}'
    sequence: !input 'on_double_press'
  - conditions:
    - '{{ command == ''on_long'' }}'
    sequence: !input 'on_long_press'
  - conditions:
    - '{{ command == ''off'' }}'
    sequence: !input 'off_short_press'
  - conditions:
    - '{{ command == ''off_double'' }}'
    sequence: !input 'off_double_press'
  - conditions:
    - '{{ command == ''off_long'' }}'
    sequence: !input 'off_long_press'
  - conditions:
    - '{{ command == ''step'' and value == [0,1,0] }}'
    sequence: !input 'up_short_press'
  - conditions:
    - '{{ command == ''step'' and value == [0,2,0] }}'
    sequence: !input 'up_long_press'
  - conditions:
    - '{{ command == ''step'' and value == [1,1,0] }}'
    sequence: !input 'down_short_press'
  - conditions:
    - '{{ command == ''step'' and value == [1,2,0] }}'
    sequence: !input 'down_long_press'

Actions that I use for this Blueprint

See the first comment. I couldn’t put a second set of ‘code’ in the post’s body here otherwise the blueprint wouldn’t properly import.

Changelog

2021, Mar 3

Added My Home Assistant import link

2021, Feb 4 #2

Initial commit was a rewrite I was testing and wasn’t ready. I’ve replace with the real final blueprint.

2021, Feb 4 #1

Initial commit.

Actions that I use for this Blueprint

See screenshot

image

To use my actions… After you create the blueprint, chose your remote then save the automation. After that, click the Automation menu button in the top-right and choose “Edit with YAML”, paste the below, then you can switch back to “Edit with UI”.
image
Paste this below “remote” after you create the automation from the blueprint:

    on_short_press:
      - service: light.turn_on
        data:
          brightness: 255
          transition: 1
        entity_id: light.master_bathroom_cabinet_lights
    on_long_press:
      - service: light.turn_on
        data:
          brightness: 1
        entity_id: light.master_bathroom_cabinet_lights
    on_double_press:
      - service: light.turn_on
        data:
          brightness: 50
          transition: 1
        entity_id: light.master_bathroom_cabinet_lights
    off_short_press:
      - service: light.turn_off
        data:
          transition: 1
        entity_id: light.master_bathroom_cabinet_lights
    off_long_press:
      - service: light.turn_off
        data:
          transition: 1
        entity_id: light.master_bathroom_cabinet_lights
    off_double_press:
      - service: light.turn_off
        entity_id: light.master_bathroom_cabinet_lights
        data:
          transition: 1
    up_short_press:
      - service: light.turn_on
        data:
          brightness_step: 15
        entity_id: light.master_bathroom_cabinet_lights
    up_long_press:
      - service: light.turn_on
        data:
          brightness_step: 50
        entity_id: light.master_bathroom_cabinet_lights
    down_short_press:
      - service: light.turn_on
        data:
          brightness_step: -15
        entity_id: light.master_bathroom_cabinet_lights
    down_long_press:
      - service: light.turn_on
        data:
          brightness_step: -50
        entity_id: light.master_bathroom_cabinet_lights

Notice for the brighten and dim actions that I use “brightness_step” instead of “brightness_step_pct” because “brightness_step” seems to be quicker.

Nice! I’ll try this out.

One note, though: Since the Up and Down buttons are intended for dimming, they always send one command immediately, and then if you keep holding them, they send a similar command with different arguments, and they continue sending the second command again every second or so until you release them. That means you may get some unexpected results with this Blueprint for those buttons if you are using short and long presses to do different things. It’s not possible to trigger the long press without also triggering a short press first, and the long press action will trigger repeatedly if you keep holding down the button. That only applies to the Up and Down buttons, though. On and Off work as expected.

Thanks for the more detailed explanation. I noted that in the up/down ‘long press’ action description.

If you’d like to support the person who got the switch working with ZHA check out their buymeacoffee.com

1 Like

After updating to the latest HA im getting this error with the 4 button switches:
Traceback (most recent call last):

  File "/usr/local/lib/python3.8/site-packages/bellows/ezsp/__init__.py", line 297, in handle_callback
    handler(*args)
  File "/usr/local/lib/python3.8/site-packages/bellows/zigbee/application.py", line 219, in ezsp_callback_handler
    self._handle_frame(*args)
  File "/usr/local/lib/python3.8/site-packages/bellows/zigbee/application.py", line 264, in _handle_frame
    self.handle_message(
  File "/usr/local/lib/python3.8/site-packages/zigpy/application.py", line 223, in handle_message
    return sender.handle_message(
  File "/usr/local/lib/python3.8/site-packages/zigpy/device.py", line 279, in handle_message
    return endpoint.handle_message(
  File "/usr/local/lib/python3.8/site-packages/zigpy/endpoint.py", line 217, in handle_message
    handler(hdr, args, dst_addressing=dst_addressing)
  File "/usr/local/lib/python3.8/site-packages/zigpy/zcl/__init__.py", line 201, in handle_message
    self.handle_cluster_request(hdr, args, dst_addressing=dst_addressing)
TypeError: handle_cluster_request() got an unexpected keyword argument 'dst_addressing'

could you point me in the right direction on this please?
It worked perfectly before.

Looks like somebody else had the same problem here: https://github.com/zigpy/zigpy/issues/606

1 Like

Thank You!!

Looks like this did not work:

pypi:
  - 'git+https://github.com/zigpy/zha-device-handlers/'
apk: []

But this did:

pypi:
  - zha-quirks==0.0.53
apk: []

there are still errors in the Log about the blueprint generating invalid yaml, but that only happens on creation of automation.
The actual automation works great!

Is the delay common on the Remotes? My Remote take more than 10 to 15 seconds to be able to connect back to HA, it is a pain. Is there any work around? Also sometimes it never connects and just go into pairing mode and drain the whole battery in just a couple of hours. Thanks for the blueprint is awesome :slight_smile:

Yea, unfortunately, this is a recognized issue with the Sengled E1E-G7F hardware and isn’t due to the ZHA integration or blueprint. My guess is because it allows a push-and-hold and double-tap the delay is how Sengled figures out if you’re doing a single or double-prep. I don’t have a Hue switch, but I’ve read they operate much faster.