-
-
Save Robbe-B/0e4904204710f998f76b01914555aed7 to your computer and use it in GitHub Desktop.
ESPhome on Action LSC Motion Sensor - Tuya TYWE3S (ESP8266-based)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This device has two chips: | |
# - an ESP8266-based WiFi Module that talks to Tuya's cloud service (when running the stock firmware) and the on-board MCU. | |
# - an unmarked Tuya microcontroller (a.k.a MCU) that acts as a power management chip and wakes up the WiFi Module | |
# when motion is detected by the PIR sensor. The WiFi Module has to talk to the MCU upon power-on to prevent immediate power-off. | |
substitutions: | |
device_name: CHANGEME | |
esphome: | |
name: '${device_name}' | |
platform: ESP8266 | |
board: esp_wroom_02 # TYWE3S modules have 2MB of on-board flash | |
on_boot: | |
then: | |
- uart.write: [0x55, 0xAA, 0x00, 0x02, 0x00, 0x01, 0x04, 0x06] # report "wifi ok, connected to router and to cloud" | |
- wait_until: mqtt.connected | |
- binary_sensor.template.publish: | |
id: pir_workspace_motion_detected | |
state: ON | |
- delay: 1s | |
- binary_sensor.template.publish: | |
id: pir_workspace_motion_detected | |
state: OFF | |
- uart.write: [0x55, 0xAA, 0x00, 0x02, 0x00, 0x01, 0x05, 0x07] # power off wifi module | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_pass | |
fast_connect: True | |
# Disable serial logging | |
logger: | |
baud_rate: 0 | |
# Enable OTA updates | |
ota: | |
password: !secret mgmt_pass | |
time: | |
- platform: sntp | |
id: sntp_time | |
uart: | |
baud_rate: 9600 | |
tx_pin: GPIO1 | |
rx_pin: GPIO3 | |
mqtt: | |
broker: !secret mqtt_broker | |
username: !secret mqtt_username | |
password: !secret mqtt_pass | |
discovery: True | |
# TODO detect motion from MCU messages | |
binary_sensor: | |
- platform: template | |
id: pir_workspace_motion_detected | |
name: 'PIR Workspace - Motion Detected' | |
device_class: motion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment