brandond / esphome-tuya_pir

ESPHome support for cheap WiFi PIR sensors
66 stars 21 forks source link

Add handling for door/window sensor messages. #1

Closed AriZuu closed 5 years ago

AriZuu commented 5 years ago

This PR adds handling for door/window sensor messages. It also changes event type comparison to use two bytes instead of just first byte, to be able to separate door sensor first boot message from motion event.

Tested with Neo Coolcam door/window server (board V5).

brandond commented 5 years ago

lgtm. I'm still hoping to have some time to move this into core at some point.

brandond commented 5 years ago

@AriZuu can I ask how you flashed your door sensor? I'm unable to get mine to talk to my USB/TTL adapter. Hooking it up to a scope shows that the CH340-based adapter I'm using isn't pulling the serial line low enough; I never had any problems with my old CP2102 board but I accidentally fried it a week or two ago.

AriZuu commented 5 years ago

@brandond I just soldered thin wires to sensor (RX, TX, GPIO0 and GND) and used FTDI -based adapter to flash. I flashed four sensors. Three of those were flashed without problems, one was more difficult but eventually after several power ups it surrendered also. So it might be that sometimes the adapter has difficulties in pulling down the line. I tried my CP210 adapter also with the problematic one, but it didn't work any better.

I connected the RX & TX lines after sensor was powered up in flash mode.

AriZuu commented 5 years ago

@brandond The cable I was using to flash was this one:

https://www.mouser.fi/ProductDetail/895-TTL-232R-3V3-WE

brandond commented 5 years ago

Thanks - that's helpful! I've got another on order but was able to get it working temporarily with a PNP transistor on the TX line from the TTL converter pulling things down to ground.

AriZuu commented 5 years ago

Offtopic, but there seems to be now also a water leak sensor and a smoke sensor. I'm a bit curious to check those out. Maybe there is similar hardware inside.

brandond commented 5 years ago

I might check those out. Don't have much need for them really, but if they're cheap I do enjoy tinkering.