Wyze Doorbell (V1) MQTT control monitoring - themactep/thingino-firmware GitHub Wiki
This page contains basic scripts used to control the blue LED on the doorbell as well as send an MQTT payload when the doorbell button is pressed.
Control the blue LED via MQTT
mqtt-listener
at /etc/scripts
containing this:
1. Create a file named #!/bin/sh
BROKER="server.lan" # MQTT broker IP address or hostname
CLIENT_ID="rear_doorbell_07ad" # MQTT client ID (needs to be unique)
PORT="1883" # MQTT broker port
CMD_TOPIC="thingino/rear_doorbell/command" # Topic to publish commands to (modify as desired)
BLUE_LED_STATE_TOPIC="thingino/rear_doorbell/blue_led" # Topic for doorbell to publish the blue LED state to (modify as desired)
USER="mqtt-user" # MQTT username
PASSWORD="mqtt-password" # MQTT password
echo "Listening for MQTT messages on topic: $TOPIC..."
mosquitto_sub -c --id "$CLIENT_ID" -h "$BROKER" -p "$PORT" -u "$USER" -P "$PASSWORD" -t "$CMD_TOPIC" | while read -r message
do
case "$message" in
"led on blue")
led blue
mosquitto_pub -h "$BROKER" -p "$PORT" -u "$USER" -P "$PASSWORD" -t "$BLUE_LED_STATE_TOPIC" -m "on" -q 1
;;
"led off")
led off
mosquitto_pub -h "$BROKER" -p "$PORT" -u "$USER" -P "$PASSWORD" -t "$BLUE_LED_STATE_TOPIC" -m "off" -q 1
;;
*)
:
;;
esac
done
2. Make it executable
chmod +x /etc/scripts/mqtt-listener
3. Enable running at startup
Add /etc/scripts/mqtt-listener &
to /etc/rc.local
(make sure exit 0
is still at the bottom).
4. Start it!
nohup /etc/scripts/mqtt-listener &
5. [Optional: Home Assistant] Add an MQTT switch
mqtt:
- switch:
name: Rear doorbell blue LED # Friendly name for the switch
command_topic: thingino/rear_doorbell/command # CMD_TOPIC defined in the script
state_topic: thingino/rear_doorbell/blue_led # BLUE_LED_STATE_TOPIC defined in the script
payload_on: 'led on blue'
payload_off: 'led off'
state_on: 'on'
state_off: 'off'
qos: 1
retain: true
Send an MQTT payload when the doorbell button is pressed
This will publish a payload of press
to thingino/rear_doorbell/press
when the doorbell button is pressed (modify the topic and payload to your preferences).
doorbell-mqtt
at /etc/scripts
(modify host, MQTT user, etc. to match your setup):
1. Create a file named #!/bin/sh
mosquitto_pub -h server.lan -p 1883 -u mqtt-user -P mqtt-password -t thingino/rear_doorbell/press -m "press" -q 1
2. Make it executable
chmod +x /etc/scripts/doorbell-mqtt
/etc/thingino-button.conf
:
3. Add this to the user mappings section of KEY_1 RELEASE 0 /etc/scripts/doorbell-mqtt
4. [Optional: Home Assistant] Use as an automation trigger
trigger:
- platform: mqtt
topic: thingino/rear_doorbell/press # Topic defined in the script
payload: 'press' # Payload defined in the script