Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIR motion sensor not sending motion data #19

Open
webfrank opened this issue Jul 14, 2020 · 1 comment
Open

PIR motion sensor not sending motion data #19

webfrank opened this issue Jul 14, 2020 · 1 comment

Comments

@webfrank
Copy link

Hi, I have a tuya WiFi Smart PIR Motion Sensor flashed with latest esphome.

This is my esphome config:

  name: pir
  platform: ESP8266
  board: esp01_1m
  arduino_version: 2.5.1
  board_flash_mode: dout
  includes:
    - sb1_uart.h

substitutions: !include secrets.yaml

wifi:
  ssid: ${wifi_ssid}
  password: ${wifi_pass}
  fast_connect: true

mqtt:
  broker: ${mqtt_broker}
  birth_message:
  shutdown_message:
  will_message:

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

ota:

logger:
  level: VERBOSE
  hardware_uart: UART1

sensor:
  - platform: wifi_signal
    name: "PIR WiFi Signal"
    update_interval: 10s
    expire_after:
    filters: []
  - platform: adc
    name: "PIR Battery"
    update_interval: 10s
    expire_after:
    pin: VCC
    filters: []

binary_sensor:
  - platform: template
    id: motion
    name: "PIR Motion"
    filters: []
    device_class: motion
    lambda: "return {};"

custom_component:
  - id: sb1_uart
    lambda: |-
      auto component = new SB1UARTComponent(id(uart0), id(motion));
      return {component};

And this is my VERBOSE log output:

[16:55:42][C][wifi:415]: WiFi:
[16:55:42][C][wifi:283]:   SSID: 'CASA'
[16:55:42][C][wifi:284]:   IP Address: 192.168.1.143
[16:55:42][C][wifi:286]:   BSSID: B8:3A:08:E8:73:C9
[16:55:42][C][wifi:287]:   Hostname: 'pir'
[16:55:42][C][wifi:291]:   Signal strength: -33 dB ▂▄▆█
[16:55:42][C][wifi:295]:   Channel: 1
[16:55:42][C][wifi:296]:   Subnet: 255.255.255.0
[16:55:42][C][wifi:297]:   Gateway: 192.168.1.1
[16:55:42][C][wifi:298]:   DNS1: 192.168.1.1
[16:55:42][C][wifi:299]:   DNS2: (IP unset)
[16:55:42][C][uart:140]: UART Bus:
[16:55:42][C][uart:142]:   TX Pin: GPIO1
[16:55:42][C][uart:145]:   RX Pin: GPIO3
[16:55:42][C][uart:147]:   Baud Rate: 9600 baud
[16:55:42][C][uart:148]:   Stop bits: 1
[16:55:42][C][uart:150]:   Using hardware serial interface.
[16:55:42][C][template.binary_sensor:018]: Template Binary Sensor 'PIR Motion'
[16:55:42][C][template.binary_sensor:018]:   Device Class: 'motion'
[16:55:42][C][logger:175]: Logger:
[16:55:42][C][logger:176]:   Level: VERBOSE
[16:55:42][C][logger:177]:   Log Baud Rate: 115200
[16:55:42][C][logger:178]:   Hardware UART: UART1
[16:55:42][C][adc:026]: ADC Sensor 'PIR Battery'
[16:55:42][C][adc:026]:   Unit of Measurement: 'V'
[16:55:42][C][adc:026]:   Accuracy Decimals: 2
[16:55:42][C][adc:026]:   Icon: 'mdi:flash'
[16:55:42][V][adc:026]:   Unique ID: 'e09806040fff-adc'
[16:55:42][C][adc:029]:   Pin: VCC
[16:55:42][C][adc:051]:   Update Interval: 10.0s
[16:55:42][C][ota:029]: Over-The-Air Updates:
[16:55:42][C][ota:030]:   Address: pir.local:8266
[16:55:42][C][mqtt:051]: MQTT:
[16:55:42][C][mqtt:053]:   Server Address: 192.168.1.4:1883 (192.168.1.4)
[16:55:42][C][mqtt:054]:   Username: ''
[16:55:42][C][mqtt:055]:   Client ID: 'pir-e09806040fff'
[16:55:42][C][mqtt:060]:   Topic Prefix: 'pir'
[16:55:42][C][mqtt:062]:   Log Topic: 'pir/debug'
[16:55:42][C][sb1:242]: SB1 UART:
[16:55:42][C][sb1:243]:   Boot Mode: NORMAL
[16:55:42][C][sb1:244]:   Product Info: {"p":"XFD2nSDKxFlGV5sV","v":"1.0.1"}
[16:55:42][C][wifi_signal.sensor:009]: WiFi Signal 'PIR WiFi Signal'
[16:55:42][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dB'
[16:55:42][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[16:55:42][C][wifi_signal.sensor:009]:   Icon: 'mdi:wifi'
[16:55:42][V][wifi_signal.sensor:009]:   Unique ID: 'e09806040fff-wifisignal'
[16:55:42][C][mqtt.sensor:024]: MQTT Sensor 'PIR WiFi Signal':
[16:55:42][C][mqtt.sensor:028]:   State Topic: 'pir/sensor/pir_wifi_signal/state'
[16:55:42][C][mqtt.sensor:024]: MQTT Sensor 'PIR Battery':
[16:55:42][C][mqtt.sensor:028]:   State Topic: 'pir/sensor/pir_battery/state'
[16:55:42][C][mqtt.binary_sensor:018]: MQTT Binary Sensor 'PIR Motion':
[16:55:42][C][mqtt.binary_sensor:019]:   State Topic: 'pir/binary_sensor/pir_motion/state'
[16:55:43][I][sb1:375]: Rebooting: SB1_STATE_RUNNING_NORMAL
[16:55:43][I][app:137]: Rebooting safely...
[16:55:43][D][sb1:392]: SB1 UART shutting down; next boot mode NORMAL
[16:57:17][I][mqtt:202]: MQTT Connected!
[16:57:17][V][sb1:142]: Sending message: header=0x55AA type=0x0002 length=0x0001
[16:57:17][D][sb1:185]: state: 10 -> 11 after 296 ms
[16:57:17][V][mqtt:372]: Publish(topic='pir/sensor/pir_battery/state' payload='3.24' retain=1)
[16:57:17][I][app:058]: setup() finished successfully!
[16:57:17][V][sensor:013]: 'PIR WiFi Signal': Received new state -36.000000
[16:57:17][D][sensor:092]: 'PIR WiFi Signal': Sending state -36.00000 dB with 0 decimals of accuracy
[16:57:17][V][mqtt:372]: Publish(topic='pir/sensor/pir_wifi_signal/state' payload='-36' retain=1)
[16:57:17][V][sb1:112]: Got message type=0x0002 length=0x0000
[16:57:17][V][sb1:176]: Checking type(2 == 3) && length(0 >= 0)
[16:57:17][V][sb1:176]: Checking type(2 == 2) && length(0 >= 0)
[16:57:17][D][sb1:185]: state: 11 -> 15 after 57 ms
[16:57:17][I][app:100]: ESPHome version 1.14.5 compiled on Jul 14 2020, 16:50:13
[16:57:17][C][wifi:415]: WiFi:
[16:57:17][C][wifi:283]:   SSID: 'CASA'
[16:57:17][C][wifi:284]:   IP Address: 192.168.1.143
[16:57:17][C][wifi:286]:   BSSID: B8:3A:08:E8:73:C9
[16:57:17][C][wifi:287]:   Hostname: 'pir'
[16:57:17][C][wifi:291]:   Signal strength: -36 dB ▂▄▆█
[16:57:17][C][wifi:295]:   Channel: 1
[16:57:17][C][wifi:296]:   Subnet: 255.255.255.0
[16:57:17][C][wifi:297]:   Gateway: 192.168.1.1
[16:57:17][C][wifi:298]:   DNS1: 192.168.1.1
[16:57:17][C][wifi:299]:   DNS2: (IP unset)
[16:57:17][C][uart:140]: UART Bus:
[16:57:17][C][uart:142]:   TX Pin: GPIO1
[16:57:17][C][uart:145]:   RX Pin: GPIO3
[16:57:17][C][uart:147]:   Baud Rate: 9600 baud
[16:57:17][C][uart:148]:   Stop bits: 1
[16:57:17][C][uart:150]:   Using hardware serial interface.
[16:57:17][C][template.binary_sensor:018]: Template Binary Sensor 'PIR Motion'
[16:57:17][C][template.binary_sensor:018]:   Device Class: 'motion'
[16:57:17][C][logger:175]: Logger:
[16:57:17][C][logger:176]:   Level: VERBOSE
[16:57:17][C][logger:177]:   Log Baud Rate: 115200
[16:57:17][C][logger:178]:   Hardware UART: UART1
[16:57:17][C][adc:026]: ADC Sensor 'PIR Battery'
[16:57:17][C][adc:026]:   Unit of Measurement: 'V'
[16:57:17][C][adc:026]:   Accuracy Decimals: 2
[16:57:17][C][adc:026]:   Icon: 'mdi:flash'
[16:57:17][V][adc:026]:   Unique ID: 'e09806040fff-adc'
[16:57:17][C][adc:029]:   Pin: VCC
[16:57:17][C][adc:051]:   Update Interval: 10.0s
[16:57:17][C][ota:029]: Over-The-Air Updates:
[16:57:17][C][ota:030]:   Address: pir.local:8266
[16:57:17][C][mqtt:051]: MQTT:
[16:57:17][C][mqtt:053]:   Server Address: 192.168.1.4:1883 (192.168.1.4)
[16:57:17][C][mqtt:054]:   Username: ''
[16:57:17][C][mqtt:055]:   Client ID: 'pir-e09806040fff'
[16:57:17][C][mqtt:060]:   Topic Prefix: 'pir'
[16:57:17][C][mqtt:062]:   Log Topic: 'pir/debug'
[16:57:17][C][sb1:242]: SB1 UART:
[16:57:17][C][sb1:243]:   Boot Mode: NORMAL
[16:57:17][C][sb1:244]:   Product Info: {"p":"XFD2nSDKxFlGV5sV","v":"1.0.1"}
[16:57:17][C][wifi_signal.sensor:009]: WiFi Signal 'PIR WiFi Signal'
[16:57:17][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dB'
[16:57:17][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[16:57:17][C][wifi_signal.sensor:009]:   Icon: 'mdi:wifi'
[16:57:17][V][wifi_signal.sensor:009]:   Unique ID: 'e09806040fff-wifisignal'
[16:57:17][C][mqtt.sensor:024]: MQTT Sensor 'PIR WiFi Signal':
[16:57:17][C][mqtt.sensor:028]:   State Topic: 'pir/sensor/pir_wifi_signal/state'
[16:57:17][C][mqtt.sensor:024]: MQTT Sensor 'PIR Battery':
[16:57:17][C][mqtt.sensor:028]:   State Topic: 'pir/sensor/pir_battery/state'
[16:57:17][C][mqtt.binary_sensor:018]: MQTT Binary Sensor 'PIR Motion':
[16:57:17][C][mqtt.binary_sensor:019]:   State Topic: 'pir/binary_sensor/pir_motion/state'
[16:57:18][V][sb1:112]: Got message type=0x0005 length=0x0005
[16:57:18][V][sb1:176]: Checking type(5 == 3) && length(5 >= 0)
[16:57:18][V][sb1:176]: Checking type(5 == 5) && length(5 >= 0)
[16:57:18][D][sb1:350]: Event message of length 5
[16:57:18][D][sb1:352]: 00: 0x65
[16:57:18][D][sb1:352]: 01: 0x04
[16:57:18][D][sb1:352]: 02: 0x00
[16:57:18][D][sb1:352]: 03: 0x01
[16:57:18][D][sb1:352]: 04: 0x00
[16:57:18][I][sb1:370]: Reset event: 0
[16:57:18][D][sb1:185]: state: 15 -> 13 after 926 ms
[16:57:18][V][sb1:112]: Got message type=0x0005 length=0x0008
[16:57:18][V][sb1:176]: Checking type(5 == 3) && length(8 >= 0)
[16:57:18][I][sb1:343]: Rebooting: SB1_STATE_EVENT_ACK
[16:57:18][I][app:137]: Rebooting safely...
[16:57:18][D][sb1:392]: SB1 UART shutting down; next boot mode NORMAL
[16:57:18][V][sb1:142]: Sending message: header=0x55AA type=0x0005 length=0x0001
[16:57:24][I][mqtt:202]: MQTT Connected!
[16:57:25][V][sb1:142]: Sending message: header=0x55AA type=0x0002 length=0x0001
[16:57:25][D][sb1:185]: state: 10 -> 11 after 132 ms
[16:57:25][V][mqtt:372]: Publish(topic='pir/sensor/pir_battery/state' payload='3.24' retain=1)
[16:57:25][I][app:058]: setup() finished successfully!
[16:57:25][V][sensor:013]: 'PIR WiFi Signal': Received new state -37.000000
[16:57:25][D][sensor:092]: 'PIR WiFi Signal': Sending state -37.00000 dB with 0 decimals of accuracy
[16:57:25][V][mqtt:372]: Publish(topic='pir/sensor/pir_wifi_signal/state' payload='-37' retain=1)
[16:57:25][V][sb1:112]: Got message type=0x0002 length=0x0000
[16:57:25][V][sb1:176]: Checking type(2 == 3) && length(0 >= 0)
[16:57:25][V][sb1:176]: Checking type(2 == 2) && length(0 >= 0)
[16:57:25][D][sb1:185]: state: 11 -> 15 after 58 ms
[16:57:25][I][app:100]: ESPHome version 1.14.5 compiled on Jul 14 2020, 16:50:13
[16:57:25][C][wifi:415]: WiFi:
[16:57:25][C][wifi:283]:   SSID: 'CASA'
[16:57:25][C][wifi:284]:   IP Address: 192.168.1.143
[16:57:25][C][wifi:286]:   BSSID: B8:3A:08:E8:73:C9
[16:57:25][C][wifi:287]:   Hostname: 'pir'
[16:57:25][C][wifi:291]:   Signal strength: -37 dB ▂▄▆█
[16:57:25][C][wifi:295]:   Channel: 1
[16:57:25][C][wifi:296]:   Subnet: 255.255.255.0
[16:57:25][C][wifi:297]:   Gateway: 192.168.1.1
[16:57:25][C][wifi:298]:   DNS1: 192.168.1.1
[16:57:25][C][wifi:299]:   DNS2: (IP unset)
[16:57:25][C][uart:140]: UART Bus:
[16:57:25][C][uart:142]:   TX Pin: GPIO1
[16:57:25][C][uart:145]:   RX Pin: GPIO3
[16:57:25][C][uart:147]:   Baud Rate: 9600 baud
[16:57:25][C][uart:148]:   Stop bits: 1
[16:57:25][C][uart:150]:   Using hardware serial interface.
[16:57:25][C][template.binary_sensor:018]: Template Binary Sensor 'PIR Motion'
[16:57:25][C][template.binary_sensor:018]:   Device Class: 'motion'
[16:57:25][C][logger:175]: Logger:
[16:57:25][C][logger:176]:   Level: VERBOSE
[16:57:25][C][logger:177]:   Log Baud Rate: 115200
[16:57:25][C][logger:178]:   Hardware UART: UART1
[16:57:25][C][adc:026]: ADC Sensor 'PIR Battery'
[16:57:25][C][adc:026]:   Unit of Measurement: 'V'
[16:57:25][C][adc:026]:   Accuracy Decimals: 2
[16:57:25][C][adc:026]:   Icon: 'mdi:flash'
[16:57:25][V][adc:026]:   Unique ID: 'e09806040fff-adc'
[16:57:25][C][adc:029]:   Pin: VCC
[16:57:25][C][adc:051]:   Update Interval: 10.0s
[16:57:25][C][ota:029]: Over-The-Air Updates:
[16:57:25][C][ota:030]:   Address: pir.local:8266
[16:57:25][C][mqtt:051]: MQTT:
[16:57:25][C][mqtt:053]:   Server Address: 192.168.1.4:1883 (192.168.1.4)
[16:57:25][C][mqtt:054]:   Username: ''
[16:57:25][C][mqtt:055]:   Client ID: 'pir-e09806040fff'
[16:57:25][C][mqtt:060]:   Topic Prefix: 'pir'
[16:57:25][C][mqtt:062]:   Log Topic: 'pir/debug'
[16:57:25][C][sb1:242]: SB1 UART:
[16:57:25][C][sb1:243]:   Boot Mode: NORMAL
[16:57:25][C][sb1:244]:   Product Info: {"p":"XFD2nSDKxFlGV5sV","v":"1.0.1"}
[16:57:25][C][wifi_signal.sensor:009]: WiFi Signal 'PIR WiFi Signal'
[16:57:25][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dB'
[16:57:25][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[16:57:25][C][wifi_signal.sensor:009]:   Icon: 'mdi:wifi'
[16:57:25][V][wifi_signal.sensor:009]:   Unique ID: 'e09806040fff-wifisignal'
[16:57:25][C][mqtt.sensor:024]: MQTT Sensor 'PIR WiFi Signal':
[16:57:25][C][mqtt.sensor:028]:   State Topic: 'pir/sensor/pir_wifi_signal/state'
[16:57:25][C][mqtt.sensor:024]: MQTT Sensor 'PIR Battery':
[16:57:25][C][mqtt.sensor:028]:   State Topic: 'pir/sensor/pir_battery/state'
[16:57:25][C][mqtt.binary_sensor:018]: MQTT Binary Sensor 'PIR Motion':
[16:57:25][C][mqtt.binary_sensor:019]:   State Topic: 'pir/binary_sensor/pir_motion/state'
[16:57:26][I][sb1:375]: Rebooting: SB1_STATE_RUNNING_NORMAL
[16:57:26][I][app:137]: Rebooting safely...
[16:57:26][D][sb1:392]: SB1 UART shutting down; next boot mode NORMAL```

I receive Battery and WiFi sensor readings but not motion.

Any help is really appreciated.
@ptrooms
Copy link

ptrooms commented Jul 15, 2020

The fact that you receive "something"is an indication that the PIR is/was triggered by motion (or initialisation). In addition, I see clearly the "MQTT Binary Sensor 'PIR Motion" message in your status message.

Note: the PIR sensor itself is monitored by an onboard (low-power operated) Micro-controller that will power-on the esp8266-chips which boots into Wifi and sending MQTT messages.
The MCU will only do this at (first) initialization and at motion detected after an period of at least 60 seconds absence of movement.
Hence. the Wifi is only active if there was a motion trigger.
FWIW: The battery-state message is only send by the MCU (to esp8266) during first initialization, after inserting the batteries and/or doing a long-press reset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants