brandond / esphome-tuya_pir

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

Wofea door/window sensor not send topics.. #9

Closed itProfi closed 4 years ago

itProfi commented 4 years ago

Hello! Use esphome 1.15-dev with you lastest commits.. It work, but on mqtt i see full debug, but not any states topics..( Скриншот 15-11-2019 130328 image

itProfi commented 4 years ago

https://ru.aliexpress.com/item/33042579114.html?spm=a2g0o.productlist.0.0.34fb1e93IskVWI&algo_pvid=2a598678-5e28-4758-b8e0-c3f97f760ca1&algo_expid=2a598678-5e28-4758-b8e0-c3f97f760ca1-12&btsid=fa2f0d81-b06b-4574-8ee6-4c354acb3ddf&ws_ab_test=searchweb0_0,searchweb201602_5,searchweb201603_55

brandond commented 4 years ago

At some point I added a power-saving enhancement; it only sends the discovery topic messages when you hold down the button to put it into OTA mode. This reduces the boot time and payload size for normal events by a significant amount.

Open up the cover and hold down the button until the light starts flashing. If you wait a bit it should time out and reboot back into normal mode, after sending config to the discovery topic.

Alternately, you can comment out this line: https://github.com/brandond/esphome-tuya_pir/blob/master/sb1_uart.h#L236

arko36 commented 4 years ago

Hi, I have same sensor and I'm trying to get this into HA. at the moment I could flash it but no idea how to see it in HA. Is there any other way ? like with static IP and detecting the connection disconnection ? what is different when the door is open or closed ? I think this is assuming the door is close when starts, what happens if I keep the door open for more than 6sec ? Thank you very much.

dkurzelewski commented 4 years ago

Hello I have the same device as @itProfi . I try also both _sb1uart.h but it's look like something is no OK. Did anyone was figure out where is the issue?

iot00tuya04/debug [I][mqtt:202]: MQTT Connected!
iot00tuya04/debug [I][app:058]: setup() finished successfully!
iot00tuya04/status online
iot00tuya04/debug [V][mqtt:372]: Publish(topic='iot00tuya04/status' payload='online' retain=1)
iot00tuya04/debug [I][app:100]: ESPHome version 1.14.3 compiled on May 23 2020, 11:00:55
iot00tuya04/debug [C][wifi:415]: WiFi:
iot00tuya04/debug [C][wifi:283]:   SSID: 'xxxxxxxxxxxxx'
iot00tuya04/debug [C][wifi:284]:   IP Address: xx.xx.xx.xx
iot00tuya04/debug [C][wifi:286]:   BSSID: xx:xx:xx:xx:xx:xx
iot00tuya04/debug [C][wifi:287]:   Hostname: 'iot00tuya04'
iot00tuya04/debug [C][wifi:291]:   Signal strength: -72 dB ▂▄▆█
iot00tuya04/debug [C][wifi:295]:   Channel: 8
iot00tuya04/debug [C][wifi:296]:   Subnet: 255.255.255.0
iot00tuya04/debug [C][wifi:297]:   Gateway: xx.xx.xx.xx
iot00tuya04/debug [C][wifi:298]:   DNS1: (IP unset)
iot00tuya04/debug [C][wifi:299]:   DNS2: (IP unset)
iot00tuya04/debug [C][uart:140]: UART Bus:
iot00tuya04/debug [C][uart:142]:   TX Pin: GPIO1
iot00tuya04/debug [C][uart:145]:   RX Pin: GPIO3
iot00tuya04/debug [C][uart:147]:   Baud Rate: 9600 baud
iot00tuya04/debug [C][uart:148]:   Stop bits: 1
iot00tuya04/debug [C][uart:150]:   Using hardware serial interface.
iot00tuya04/debug [C][template.binary_sensor:018]: Template Binary Sensor 'Door Closure'
iot00tuya04/debug [C][template.binary_sensor:018]:   Device Class: 'door'
iot00tuya04/debug [C][logger:175]: Logger:
iot00tuya04/debug [C][logger:176]:   Level: VERY_VERBOSE
iot00tuya04/debug [C][logger:177]:   Log Baud Rate: 115200
iot00tuya04/debug [C][logger:178]:   Hardware UART: UART1
iot00tuya04/debug [C][adc:026]: ADC Sensor 'Door Battery'
iot00tuya04/debug [C][adc:026]:   Unit of Measurement: 'V'
iot00tuya04/debug [C][adc:026]:   Accuracy Decimals: 2
iot00tuya04/debug [C][adc:026]:   Icon: 'mdi:flash'
iot00tuya04/debug [V][adc:026]:   Unique ID: 'f4cfa2ce11d4-adc'
iot00tuya04/debug [C][adc:029]:   Pin: VCC
iot00tuya04/debug [C][adc:051]:   Update Interval: 4294967.5s
iot00tuya04/debug [C][ota:029]: Over-The-Air Updates:
iot00tuya04/debug [C][ota:030]:   Address: xx.xx.xx.xx:8266
iot00tuya04/debug [C][ota:032]:   Using Password.
iot00tuya04/debug [C][mqtt:051]: MQTT:
iot00tuya04/debug [C][mqtt:053]:   Server Address: xx.xx.xx.xx:1883 (xx.xx.xx.xx)
iot00tuya04/debug [C][mqtt:054]:   Username: 'mqttbind'
iot00tuya04/debug [C][mqtt:055]:   Client ID: 'iot00tuya04-f4cfa2ce11d4'
iot00tuya04/debug [C][mqtt:060]:   Topic Prefix: 'iot00tuya04'
iot00tuya04/debug [C][mqtt:062]:   Log Topic: 'iot00tuya04/debug'
iot00tuya04/debug [C][mqtt:065]:   Availability: 'iot00tuya04/status'
iot00tuya04/debug [C][sb1:243]: SB1 UART:
iot00tuya04/debug [C][sb1:244]:   Boot Mode: NORMAL
iot00tuya04/debug [C][sb1:245]:   Product Info:
iot00tuya04/debug [C][mqtt.sensor:024]: MQTT Sensor 'Door Battery':
iot00tuya04/debug [C][mqtt.sensor:028]:   State Topic: 'iot00tuya04/sensor/door_battery/state'
iot00tuya04/debug [C][mqtt.binary_sensor:018]: MQTT Binary Sensor 'Door Closure':
iot00tuya04/debug [C][mqtt.binary_sensor:019]:   State Topic: 'iot00tuya04/binary_sensor/door_closure/state'
iot00tuya04/debug [D][sb1:186]: state: 1 -> 0 after 1016 ms
iot00tuya04/debug [V][sb1:143]: Sending message: header=0x55AA type=0x0001 length=0x0000
iot00tuya04/debug [VV][uart:173]:     Wrote 0b01010101 (0x55)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b10101010 (0xAA)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000001 (0x01)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [VV][uart:163]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [D][sb1:186]: state: 0 -> 1 after 50 ms
iot00tuya04/debug [D][sb1:186]: state: 1 -> 0 after 1011 ms
iot00tuya04/debug [V][sb1:143]: Sending message: header=0x55AA type=0x0001 length=0x0000
iot00tuya04/debug [VV][uart:173]:     Wrote 0b01010101 (0x55)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b10101010 (0xAA)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000001 (0x01)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [VV][uart:163]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [D][sb1:186]: state: 0 -> 1 after 50 ms
iot00tuya04/debug [D][sb1:186]: state: 1 -> 0 after 1004 ms
iot00tuya04/debug [V][sb1:143]: Sending message: header=0x55AA type=0x0001 length=0x0000
iot00tuya04/debug [VV][uart:173]:     Wrote 0b01010101 (0x55)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b10101010 (0xAA)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000001 (0x01)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [VV][uart:173]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [VV][uart:163]:     Wrote 0b00000000 (0x00)
iot00tuya04/debug [D][sb1:186]: state: 0 -> 1 after 54 ms
esphome:
  name: iot00tuya04
  platform: ESP8266
  board: esp01_1m
  includes:
    - sb1_uart.h

wifi:
  ssid: "xxxxxxxxxxxxxxx"
  password: "xxxxxxxxxxxxxxx"
  fast_connect: true
  manual_ip:
    static_ip: xx.xx.xx.xx
    gateway: xx.xx.xx.xx
    subnet: 255.255.255.0

mqtt:
  broker: xx.xx.xx.xx
  username: mqttbind
  password: xxxxxxxxxxxxxxx

uart:
  - tx_pin: 1
    rx_pin: 3
    baud_rate: 9600
    id: uart0

logger:
  level: VERY_VERBOSE
  hardware_uart: UART1

ota:
  password: "metall1"

sensor:  
  - platform: adc
    name: "Door Battery"
    update_interval: never
    expire_after:
    pin: VCC
    filters: []

binary_sensor:
  - platform: template
    id: door
    name: "Door Closure"
    filters: []
    device_class: door
    lambda: "return {};"

custom_component:
  - id: sb1_uart
    lambda: |-
      auto component = new SB1UARTComponent(id(uart0), id(door));
      return {component};
dkurzelewski commented 4 years ago

Maybe someone is interest, I solved my problem by flash 'other' firmware and setup this rules:

rule1 ON Wifi#Connected DO backlog serialsend5 55 AA 00 01 00 00 00; delay 10; serialsend5 55 AA 00 02 00 01 04 06; delay 3; serialsend5 55 AA 00 05 00 01 00 05; ENDON
rule2 ON TuyaReceived#Data=55aa000200000155aa0005000501010001010d DO POWER ON ENDON ON TuyaReceived#Data=55aa000200000155aa0005000501010001000c DO POWER OFF ENDON

All works. Because I solved my problem I will not go deeper.