I have one of the no neutral Xiaomi wall switches, link below, controlling 2 Cree zigbee bulbs, 1 Ikea zigbee bulb and 1 Sengled zigbee bulb. I do the control via the HA automation below. don’t get me wrong it is no blaze in responsiveness, however it is 1 second or less. As much as I like Z2M’s MQTT method, if you want speed, either settting up a direct zigbee light group controlled by a binding to a zigbee switch is the fastest. And yes, ZHA with it’s internal message model in HA is faster than Z2M going via MQTT.
As to your point on how Aqara switches connect, the no neutral Xiaomi Aqara switch I cited is connected to a 3rd Reality Smart Plug router that connects back to the USB connected TI CC2652P2 coordinator running 20211217 firmware revision. I am running Z2M 1.32.1.
I just unplugged the 3rd Reality plug that the Aqara switch was routing via and within 30 seconds it has re-routed via a Centralite wall switch and was turning on and off the 4 bulbs with no issues. I plugged back in the 3rd Reality plug back in and by the time I refreshed the Z2M map, the Aqara switch show routes back to coordinator via both the 3rd Reality and the Centralite plugs. The lights continue to turn on and off fine.
‘When I click on “Run Action” instead of using the wireless switch to toggle the lights it’s almost instantaneous. So perhaps the way I set up the button clicking trigger since recently is slowing the automation down too?’
This does seem to indicate the switch and/or the automation is introducing some type of ‘bad’ behavior. I cannot find it in any of my switch setting, however I seem to remember some switch behavior setting that you can set via Z2M’s options for devices (and general setting perhaps)
https://www.zigbee2mqtt.io/devices/WS-USC02.html#xiaomi-ws-usc02
I use some simple linux bash scripts such as shown below to monitor and send MQTT message to Z2M to help me understand messages and timing. You might find running something similar on a a machine, the ssh into the machine from a notebook while you stand in front of the switch and toggle it. As shown, the bash script below just prints out the MQTT messages from the Aqara switch as you press the top or bottom button:
user@ud-22-04-01:~/zigbee-test$ ./aqara-switch-master-bedroom.sh
Bash version 5.1.16(1)-release...
{"device_temperature":24,"elapsed":453077,"flip_indicator_light":"ON","last_seen":"2023-09-17T16:27:09-07:00","linkquality":87,"operation_mode_bottom":"control_relay","power_outage_count":4,"power_outage_memory":true,"state":"OFF","state_bottom":"ON","state_top":"OFF"}
{"action":"single_bottom","device_temperature":24,"elapsed":634,"flip_indicator_light":"ON","last_seen":"2023-09-17T16:27:09-07:00","linkquality":83,"operation_mode_bottom":"control_relay","power_outage_count":4,"power_outage_memory":true,"state":"OFF","state_bottom":"ON","state_top":"OFF"}
{"device_temperature":24,"elapsed":252,"flip_indicator_light":"ON","last_seen":"2023-09-17T16:27:09-07:00","linkquality":87,"operation_mode_bottom":"control_relay","power_outage_count":4,"power_outage_memory":true,"state":"OFF","state_bottom":"ON","state_top":"ON"}
{"action":"single_top","device_temperature":24,"elapsed":623,"flip_indicator_light":"ON","last_seen":"2023-09-17T16:27:10-07:00","linkquality":87,"operation_mode_bottom":"control_relay","power_outage_count":4,"power_outage_memory":true,"state":"OFF","state_bottom":"ON","state_top":"ON"}
{"device_temperature":24,"elapsed":234,"flip_indicator_light":"ON","last_seen":"2023-09-17T16:27:10-07:00","linkquality":83,"operation_mode_bottom":"control_relay","power_outage_count":4,"power_outage_memory":true,"state":"OFF","state_bottom":"OFF","state_top":"ON"}
{"action":"single_bottom","device_temperature":24,"elapsed":606,"flip_indicator_light":"ON","last_seen":"2023-09-17T16:27:11-07:00","linkquality":83,"operation_mode_bottom":"control_relay","power_outage_count":4,"power_outage_memory":true,"state":"OFF","state_bottom":"OFF","state_top":"ON"}
{"device_temperature":24,"elapsed":232,"flip_indicator_light":"ON","last_seen":"2023-09-17T16:27:11-07:00","linkquality":80,"operation_mode_bottom":"control_relay","power_outage_count":4,"power_outage_memory":true,"state":"OFF","state_bottom":"OFF","state_top":"OFF"}
{"action":"single_top","device_temperature":24,"elapsed":555,"flip_indicator_light":"ON","last_seen":"2023-09-17T16:27:12-07:00","linkquality":87,"operation_mode_bottom":"control_relay","power_outage_count":4,"power_outage_memory":true,"state":"OFF","state_bottom":"OFF","state_top":"OFF"}
#!/bin/bash
echo "Bash version ${BASH_VERSION}..."
while :
do
PRI=$(mosquitto_sub -C 1 -h 192.168.2.242 -t zigbee2mqtt/0x54ef4410006292fb)
printf "%s\n" "$PRI"
# echo $PRI
done
- alias: Master Bedroom Wall Switch Bottom On
trigger:
- platform: mqtt
topic: zigbee2mqtt/0x54ef9510006ad2fb
payload: 'ON'
value_template: '{{ value_json.state_bottom | default(''NA'') }}'
action:
- service: light.turn_on
data:
entity_id:
- light.master_bedroom_table_light
- light.master_bedroom_dresser_light
- light.master_bedroom_closet_light
- light.master_bedroom_west_table_light
brightness: 255
mode: single
This script example just changes the LED colors on a gledopto zigbee LED strip controller a speed set by the ‘zdelay’ variable.
#!/bin/bash
echo "Bash version ${BASH_VERSION}..."
zdelay=0.25
echo $zdelay
while :
bright=$(shuf -i 0-254 -n 1)
#echo "brightness : $bright"
z="{\"brightness\": $bright}"
mosquitto_pub -t 'zigbee2mqtt/0x00124b001a066793/set' -m "$z"
for i in {1..20..1}
do
red=$(shuf -i 0-255 -n 1)
green=$(shuf -i 0-255 -n 1)
blue=$(shuf -i 0-255 -n 1)
z="{\"color\":{\"r\":$red,\"g\":$green,\"b\":$blue},\"transition\":0}"
# echo $z
mosquitto_pub -t 'zigbee2mqtt/0x00124b001a066793/set' -m "$z"
sleep $zdelay
done
do
for i in {150..500..10}
do
#echo "color temp : $i"
z="{\"color_temp\": $i,\"transition\":0}"
#echo $z
mosquitto_pub -t 'zigbee2mqtt/0x00124b001a066793/set' -m "$z"
sleep $zdelay
done
for i in {500..150..-10}
do
#echo "color temp : $i"
z="{\"color_temp\": $i,\"transition\":0}"
#echo $z
mosquitto_pub -t 'zigbee2mqtt/0x00124b001a066793/set' -m "$z"
sleep $zdelay
done
done
Good hunting!