找回密码
 立即注册
楼主: yb997471

[人体存在] 27.1元打造零延迟人体存在传感器:我的智能家居改造记

[复制链接]

3

主题

45

回帖

223

积分

中级会员

积分
223
金钱
175
HASS币
0
 楼主| 发表于 2025-5-18 22:32:42 | 显示全部楼层
本帖最后由 yb997471 于 2025-5-18 22:33 编辑
完整代码,自己复制一份即可。
esphome:
  name: weishengjian1-2410c
  friendly_name: weishengjian1_2410c

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "2UU/ayxp7RWpUUlPiqOE+9PGPNXcKI="

ota:
  - platform: esphome
    password: "6ce8c4512ebe363d09f"

wifi:
  ssid: ithome_2.4
  password: 123456

  # Optional manual IP
  manual_ip:
    static_ip: 192.168.0.231
    gateway: 192.168.3.1
    subnet: 255.255.255.0
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "chufangld2410AP"
    password: "12345678"

# prefix for Home Assistant entities --> CHANGE to our yown prefix
substitutions:
  device_name: _ 

web_server:
  port: 8080

captive_portal:


# UART for the LD2410 board --> CHANGE to your GPIO!!
uart:
  #可以手动指定 UART 组件的 ID 使用
  id: uart_bus
  tx_pin:
    number: GPIO1
  rx_pin: 
    number: GPIO3
  baud_rate: 256000
  parity: NONE
  stop_bits: 1
 

ld2410:

switch:
  #该开关允许您控制 LD2410 传感器
  - platform: ld2410
    engineering_mode:
      #启用/禁用工程模式
      name: ${device_name}engineering_mode
    bluetooth:
      #打开/关闭蓝牙适配器
      name: ${device_name}control_bluetooth

button: 
  - platform: restart
  #单独
    name: ${device_name}restart_device  

  - platform: ld2410
    factory_reset:
      #此命令用于将所有配置值还原为其原始值
      name: ${device_name}factory_reset
    restart:
      #重启设备
      name: ${device_name}restart
    query_params:
      #刷新设备的所有传感器值
      name: ${device_name}query_params

#该传感器允许您使用 LD2410 传感器执行不同的 测量。
sensor:
  - platform: ld2410
    light:
      #可选,int):在工程模式下,表示光敏度,否则。 介于 和 包含之间的值。尽管该值似乎是完全黑暗时的最低值
      name: ${device_name}light_sensitivity
    moving_distance:
      #检测到的移动目标的距离(以厘米为单位)
      name : ${device_name}moving_distance
    still_distance:
      #检测到的静止目标的距离(以厘米为单位)
      name: ${device_name}still_distance
    moving_energy:
      #移动目标的能量。 介于 和 包含之间的值
      name: ${device_name}moving_energy
    still_energy:
      #静止目标的能量。 介于 和 包含之间的值
      name: ${device_name}still_energy
    detection_distance:
      #距离目标的距离(以厘米为单位)
      name: ${device_name}detection_distance
    g0:
      #第 X 个门的能量 门的移动能量&门的静止能量
      move_energy:
        name: ${device_name}g0_move_energy
      still_energy:
        name: ${device_name}g0_still_energy
    g1:
      move_energy:
        name: ${device_name}g1_move_energy
      still_energy:
        name: ${device_name}g1_still_energy
    g2:
      move_energy:
        name: ${device_name}g2_move_energy
      still_energy:
        name: ${device_name}g2_still_energy
    g3:
      move_energy:
        name: ${device_name}g3_move_energy
      still_energy:
        name: ${device_name}g3_still_energy
    g4:
      move_energy:
        name: ${device_name}g4_move_energy
      still_energy:
        name: ${device_name}g4_still_energy
    g5:
      move_energy:
        name: ${device_name}g5_move_energy
      still_energy:
        name: ${device_name}g5_still_energy
    g6:
      move_energy:
        name: ${device_name}g6_move_energy
      still_energy:
        name: ${device_name}g6_still_energy
    g7:
      move_energy:
        name: ${device_name}g7_move_energy
      still_energy:
        name: ${device_name}g7_still_energy
    g8:
      move_energy:
        name: ${device_name}g8_move_energy
      still_energy:
        name: ${device_name}g8_still_energy

binary_sensor:
  - platform: ld2410
    has_target:
      #如果为 true,则目标检测到静止或移动
      name: ${device_name}presence
    has_moving_target:
      #如果为 true,则检测到移动目标
      name: ${device_name}moving_target
    has_still_target:
      #如果为 true,则检测到静止目标
      name: ${device_name}still_target
    out_pin_presence_status:
      #当处于工程模式时,指示 OUT 引脚是否指示存在,否则。 OUT 引脚指示取决于光功能配置
      name: ${device_name}engineering_occupancy

# LD2410 PINOUT GPIO --> CHANGE to your own GPIO!!
  - platform: gpio
    pin: GPIO5
    name: ${device_name}occupancy
    device_class: presence

number:

  - platform: ld2410
    timeout:
      #状态保持存在的时间(以秒为单位) 离开后
      name: ${device_name}timeout
    light_threshold:
      #设置 light 函数的 light 阈值
      name: ${device_name}light_threshold
    max_move_distance_gate:
      #:用于移动检测的最大距离门
      name: ${device_name}max_move_distance_gate
    max_still_distance_gate:
      #用于静止检测的最大距离门
      name: ${device_name}max_still_distance_gate
    g0:
      #第 X 个门的阈值
      move_threshold:
        #运动检测门的阈值。 对于所考虑的门 (距离) ,高于此级别,将触发移动检测
        name: ${device_name}g0_move_threshold
      still_threshold:
        #用于静止检测的门阈值。 对于所考虑的门 (距离) ,高于此水平时,仍将触发检测
        name: ${device_name}g0_still_threshold
    g1:
      move_threshold:
        name: ${device_name}g1_move_threshold
      still_threshold:
        name: ${device_name}g1_still_threshold
    g2:
      move_threshold:
        name: ${device_name}g2_move_threshold
      still_threshold:
        name: ${device_name}g2_still_threshold
    g3:
      move_threshold:
        name: ${device_name}g3_move_threshold
      still_threshold:
        name: ${device_name}g3_still_threshold
    g4:
      move_threshold:
        name: ${device_name}g4_move_threshold
      still_threshold:
        name: ${device_name}g4_still_threshold
    g5:
      move_threshold:
        name: ${device_name}g5_move_threshold
      still_threshold:
        name: ${device_name}g5_still_threshold
    g6:
      move_threshold:
        name: ${device_name}g6_move_threshold
      still_threshold:
        name: ${device_name}g6_still_threshold
    g7:
      move_threshold:
        name: ${device_name}g7_move_threshold
      still_threshold:
        name: ${device_name}g7_still_threshold
    g8:
      move_threshold:
        name: ${device_name}g8_move_threshold
      still_threshold:
        name: ${device_name}g8_still_threshold

select:
  - platform: ld2410
    distance_resolution:
      #控制浇口距离分辨率
      name: ${device_name}distance_resolution
    light_function:
      #如果设置,将根据光阈值影响 OUT 引脚值
      name: ${device_name}ligh_function
    out_pin_level:
      #控制 OUT 引脚值
      name: ${device_name}out_pin_level
回复

使用道具 举报

3

主题

45

回帖

223

积分

中级会员

积分
223
金钱
175
HASS币
0
 楼主| 发表于 2025-5-19 13:59:03 | 显示全部楼层
bugensui 发表于 2025-5-5 11:33
5伏转3.3伏有什么用?很多开发板不都是5v usb输入,并且板子上支持3.3和5v的吗? ...

8266 需要3.3伏电压
回复

使用道具 举报

3

主题

45

回帖

223

积分

中级会员

积分
223
金钱
175
HASS币
0
 楼主| 发表于 2025-5-19 14:00:12 | 显示全部楼层
gasment 发表于 2025-5-6 09:47
卫浴这种裸露的我不敢用,之前因为水汽报销了个领普ES1,现在用防水的ES3

还真没有考虑水蒸气这个东西,使用一段时间再看吧,不行换成防水的
回复

使用道具 举报

3

主题

45

回帖

223

积分

中级会员

积分
223
金钱
175
HASS币
0
 楼主| 发表于 2025-5-19 14:01:37 | 显示全部楼层

已发yaml ,看一下置顶
回复

使用道具 举报

0

主题

14

回帖

116

积分

注册会员

积分
116
金钱
102
HASS币
0
发表于 2025-5-19 15:40:25 | 显示全部楼层
yb997471 发表于 2025-5-19 14:01
已发yaml ,看一下置顶

非常感谢楼主的无私分享精神,爆赞
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-6-1 14:53 , Processed in 0.235390 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表