Using Blueprint switch ZG-101ZS

Hi there,

I am using a ZG-101ZS switch combined with the blueprint ZHA - Tuya 4-Button Scene Switch

The switch panel is integrated in HA and it works fine with a single lamp, but I want to do more than that.

What I am trying to achieve:
There are 4 buttons on the switch (with single/double and long press modes). Huiskamer = Livingroom and Badkamer = Bathroom

  • First button (single click = taking a shower and get dressed): turn on the “badkamer light (= a Sonoff ZBMINI-L2 Extreme)” + turn on the radio station (arrow classic rock) through my sonos “badkamer” and these actions has to stop after 45 minutes.
  • Second button (single click = morning routine): Same actions as the first button, but it has to stop after 20 minutes.
  • Third button (single click = only light): Turn on the light of the “badkamer”
  • Third button (double click): Turn off the lights of the “badkamer”
  • Fourth button (single click): Turn the lights (all HUE lights) in the “huiskamer” off
  • Fourth button (double click): Turn the lights (all HUE lights) in the “huiskamer” on

The action of the fourth button is working, so this is great.
But when I am pressing the first, second or third button, the lights wil go on. But the Sonos isn’t playing any music and after 45 minutes the lights or the music (when choose this option manually) won’t go “off”.
Is there anybody who can help me with this issue? Thanks in advance.

I will paste my YAML code.

alias: Badkamer Switch
description: ""
use_blueprint:
  path: amrutprabhu/ZHA_Tuya_4_Button_Scene_Switch.yaml
  input:
    tuya_4button_scene_switch: 1ef0a18230d6b172c4bde8831cb58d7c
    button_one_short_press:
      - type: turn_on
        device_id: 8c9fb5d3c5c7bc06a17c2836b17a24ce
        entity_id: 16784c3261799fad932a77abb8a6baf5
        domain: switch
      - action: media_player.play_media
        target:
          entity_id: media_player.sonos_badkamer
        data:
          media_content_id: FV:2/10
          media_content_type: favorite_item_id
        metadata:
          title: Arrow Classic Rock
          thumbnail: https://cdn-profiles.tunein.com/s6702/images/logoq.jpg?t=152752
          media_class: genre
          children_media_class: null
          navigateIds:
            - {}
            - media_content_type: favorites
              media_content_id: ""
            - media_content_type: favorites_folder
              media_content_id: object.item.audioItem.audioBroadcast
      - delay:
          hours: 0
          minutes: 45
          seconds: 0
          milliseconds: 0
    button_one_double_press: []
    button_two_short_press:
      - type: turn_on
        device_id: 8c9fb5d3c5c7bc06a17c2836b17a24ce
        entity_id: 16784c3261799fad932a77abb8a6baf5
        domain: switch
      - action: media_player.play_media
        target:
          entity_id: media_player.sonos_badkamer
        data:
          media_content_id: FV:2/10
          media_content_type: favorite_item_id
        metadata:
          title: Arrow Classic Rock
          thumbnail: https://cdn-profiles.tunein.com/s6702/images/logoq.jpg?t=152752
          media_class: genre
          children_media_class: null
          navigateIds:
            - {}
            - media_content_type: favorites
              media_content_id: ""
            - media_content_type: favorites_folder
              media_content_id: object.item.audioItem.audioBroadcast
      - delay:
          hours: 0
          minutes: 20
          seconds: 0
          milliseconds: 0
    button_three_short_press:
      - type: turn_on
        device_id: 8c9fb5d3c5c7bc06a17c2836b17a24ce
        entity_id: 16784c3261799fad932a77abb8a6baf5
        domain: switch
    button_three_double_press:
      - type: turn_off
        device_id: 8c9fb5d3c5c7bc06a17c2836b17a24ce
        entity_id: 16784c3261799fad932a77abb8a6baf5
        domain: switch
    button_four_short_press:
      - action: light.turn_off
        metadata: {}
        data: {}
        target:
          device_id: c8e79ce8bee26badaaea0845f31719af
    button_four_double_press:
      - action: light.turn_on
        metadata: {}
        data:
          kelvin: 3185
        target:
          device_id: c8e79ce8bee26badaaea0845f31719af

Hello remoke1985,
Welcome to the forum. Let’s see if I can be of any assistance.

If you are having a problem with a specific Blueprint, the first point of contact is in the Forum pose in the Blueprint Exchange (or Github) post that you found the Blueprint in originally.
There are people there using the equipment and the blueprint and will be able to give you more accurate information regarding your problem.
Here you might find someone.

Hey, jsut a a short question: How do you get the switch into home assistant? With z2mqtt the device seems to be not supported.

1 Like

Using the new action events in Zigbee2MQTT 2.0 - Configuration / Zigbee - Home Assistant Community

Did you ever get this to work?

Asking b/c I’ve got my hands on one of those ZG 101zs 4 button scene switches and I can ‘pickup’ a short, double, and long press on every one of the 4 buttons - so in theory I would sit with a 12-button switch on my hands :face_with_peeking_eye:

My Home Assistant 'fu is not nearly good enough to battle this, though – I can get it to toggle one device but somehow I can only get that one device to respond to the automation - listed below (b4_short does not work - only if I let it toggle the same device as b3)

Anybody got any idea what that might be?

alias: "ZG101zs: use each button separately"
triggers:
  - id: b1_short
    event_type: zha_event
    event_data:
      device_ieee: a4:c1:38:bd:5b:fe:27:95
      endpoint_id: 1
      command: remote_button_short_press
    trigger: event
  - id: b2_attr
    event_type: zha_event
    event_data:
      device_ieee: a4:c1:38:bd:5b:fe:27:95
      endpoint_id: 2
      command: attribute_updated
    trigger: event
  - id: b3_short
    event_type: zha_event
    event_data:
      device_ieee: a4:c1:38:bd:5b:fe:27:95
      endpoint_id: 3
      command: remote_button_short_press
    trigger: event
  - id: b3_double
    event_type: zha_event
    event_data:
      device_ieee: a4:c1:38:bd:5b:fe:27:95
      endpoint_id: 3
      command: remote_button_double_press
    trigger: event
  - id: b4_short
    event_type: zha_event
    event_data:
      device_ieee: a4:c1:38:bd:5b:fe:27:95
      endpoint_id: 4
      command: remote_button_short_press
    trigger: event
actions:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ trigger.id == 'b3_short' }}"
        sequence:
          - action: light.toggle
            target:
              device_id:
                - 6d9fa5a8267c3271b71206c7d7c0d695
            data: {}
      - conditions:
          - condition: template
            value_template: "{{ trigger.id == 'b4_short' }}"
        sequence:
          - action: light.toggle
            target:
              device_id:
                - d869c351923e23eefb7cf3e7c769ded6
            data: {}
    default: []
mode: single

I just added a comment on the blueprint, but I had to modify the triggers to only listen for the commands. Looking at the zha_event in the developer tools I see it fires off ~3 events with every click so it probably cancels the last run and overwrites the variables. Most likely there is a more elegant way to do this, but I updated it then uploaded it with the file editor /homeassistant/blueprints/automation/JoaoCostaIFG and it seems to work.

trigger:
- platform: event
  event_type: zha_event
  event_data:
    device_id: !input 'tuya_4button_scene_switch'
    command: remote_button_short_press
- platform: event
  event_type: zha_event
  event_data:
    device_id: !input 'tuya_4button_scene_switch'
    command: remote_button_double_press
- platform: event
  event_type: zha_event
  event_data:
    device_id: !input 'tuya_4button_scene_switch'
    command: remote_button_long_press

I’ve learned that if I go to the device that I’d like to control with one of the buttons on the ZG-101ZS and start an automation then I can make all 12 ‘modes’ work - only thing is my “code” is spread across a lot of things-that-get-controlled in stead of one place; the ZG.

messy but it works :sweat_smile: