feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

Door sensor deep sleep for bk7231n board

Open yaminahacs opened this issue 1 year ago • 21 comments

Door sensor deep sleep for bk7231n board

Describe the problem you have/What new integration you would like

Add door sensor deep sleep for bk7231n board

Please describe your use case for this integration and alternatives you've tried:

ESPHOME deep sleep not working for bk72xx platform

Additional context

yaminahacs avatar Nov 08 '23 06:11 yaminahacs

I didn't know how to enable deep sleep too

imorlxs avatar Dec 12 '23 22:12 imorlxs

My temporary solution

script:
    - id: scr
      then:
        - wifi.enable:
        - delay: 30s
        - wifi.disable:
      mode: restart
      
binary_sensor:
  - platform: gpio
    device_class: door
    name: Door
    pin: P22
    on_state:
      then:
        - script.execute: scr

Mostalk avatar Dec 24 '23 06:12 Mostalk

ThanksMy iPad will find youOn Dec 24, 2023, at 08:44, Ivan Shevchenko @.***> wrote: My temporary solution script: - id: scr then: - wifi.enable: - delay: 30s - wifi.disable: mode: restart

binary_sensor:

  • platform: gpio device_class: door name: Door pin: P22 on_state: then: - script.execute: scr

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

yaminahacs avatar Dec 27 '23 14:12 yaminahacs

Having functional deep sleep will help in a long run.

in mean time, I've been trying to get up to speed with the project

YuraBogdan avatar Jan 21 '24 23:01 YuraBogdan

I've implemented your solution as I'm trying to find the deep sleep code for the exact same type of sensor... Below my running ESPHome config as it works now, quite well. Please comments are needed as I'm not really sure it is efficent enough!

esphome:
  name: basement-door-sensor
  friendly_name: basement_door_sensor
  on_boot:
    priority: 10
    then:
      - switch.turn_on: batt_dv
      - script.execute: scr
bk72xx:
  board: cb3s
  framework:
    version: dev

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: ""

ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot in case wifi connection fails
  ap:
    ssid: "Basement-Door-Sensor"
    password: "1234567890"

web_server:
  port: 80
  version: 2
  include_internal: true
  ota: true

captive_portal:

script:
    - id: scr
      then:
        - wifi.enable:
        - delay: 30s
        - wifi.disable:
      mode: restart    
binary_sensor:
  - platform: gpio
    device_class: door
    name: Door
    pin: P8
    on_state:
      then:
        - output.turn_on: light_output
        - delay: 500ms
        - output.turn_off: light_output 
        - script.execute: scr    
switch:
  - platform: gpio
    id: batt_dv
    pin: P14
sensor:
  - platform: adc
    pin: ADC3
    id: "VCC"
    name: "Battery Level"
    filters:
      - multiply: 2.4
  - platform: template
    name: "Battery Level (%)"
    unit_of_measurement: '%'
    update_interval: 240s
    lambda: |-
      return ((id(VCC).state /3.0) * 100.00);
light:
  - platform: binary
    name: "Activity LED"
    output: light_output

output:
  - id: light_output
    platform: gpio
    pin: P26

grego1981 avatar Jan 24 '24 14:01 grego1981

Any updates?

Mostalk avatar Feb 22 '24 13:02 Mostalk

There is some work going on the LibreTiny to support it in ESPHome, but I believe it will take some time until we have Deep Sleep for these chips.

0x3333 avatar Feb 22 '24 13:02 0x3333

Does the above script work? What is the power consumption? I have two water sensors operating with 2xAAA batteries and I'd really like to replace the tuya firmware with something else.

jon-daemon avatar Mar 09 '24 22:03 jon-daemon