Awe7 发表于 2024-2-23 23:24:33

求个esphome配置文件

本帖最后由 Awe7 于 2024-3-1 18:19 编辑

esphome配置,创建一个自动化 用pir501控制一个继电器有人时打开继电器,感应到无人时延迟10秒关闭继电器。再用一个翘板开关控制状态,来控制感应到无人时延迟10秒关闭继电器这个动作是否执行。

DDDear 发表于 2024-2-24 08:13:37

可以问问AI

Awe7 发表于 2024-2-24 10:03:54

DDDear 发表于 2024-2-24 08:13
可以问问AI

ai一直生成不了合适的0.0

kjjuhfv 发表于 2024-2-24 13:59:47

第一个要求很简单
第二个要求我看不懂 要不你重新描述一下

george65 发表于 2024-2-24 14:23:54

kjjuhfv 发表于 2024-2-24 13:59
第一个要求很简单
第二个要求我看不懂 要不你重新描述一下

感应到无人时延迟10秒关闭继电器<<==用一个翘板开关控制状态这个动作是否执行

kjjuhfv 发表于 2024-2-24 14:33:14

Pir501在感应10秒没人的时候就自动关闭继电器了
你这翘班开关没用啊
都关闭继电器了你还要去按它吗?

Awe7 发表于 2024-2-24 14:35:41

本帖最后由 Awe7 于 2024-2-24 14:45 编辑

kjjuhfv 发表于 2024-2-24 13:59
第一个要求很简单
第二个要求我看不懂 要不你重新描述一下
binary_sensor:
- platform: gpio
    pin:
      number: 14
      mode: INPUT_PULLUP
    name: "SWITCHguodao"
    id: kaiguan
    on_press:
      then:
      - switch.toggle: relay

- platform: gpio
    pin:
      number: 12
      mode: INPUT_PULLUP
    name: "erlouganyingqi"
    device_class: motion
    id: pir501
    filters:
      - delayed_on: 800ms
      - delayed_off: 10s       on_press:
      then:
      - if:
            condition:
            and:
                - binary_sensor.is_on: pir501

            then:
            - logger.log: "Detected somebody activity"
            - switch.turn_on: relay

            else:
            - logger.log: "There is no one around"
            - switch.turn_off: relay

    on_release:                           
      then:
      - switch.turn_off: relay



switch:
- platform: gpio
    name: "SWITCHguodao"
    pin: GPIO4
    id: relay


目前配置是这样的,但是因为pir501的感应距离不够。导致人在灯下10s内未触发pir会自动关闭继电器。
所以需要用翘板开关来控制(自动关闭pir的自动化).人手动打开翘板开关灯一直亮 ,关闭翘板开关恢复10s内未检测到自动关.

Awe7 发表于 2024-2-24 14:38:11

george65 发表于 2024-2-24 14:23
感应到无人时延迟10秒关闭继电器

对的就是这个意思.试过添加到

   on_state:
      - if:
          condition:
            and:
            - binary_sensor.is_on: pir501
            - binary_sensor.is_on: kaiguan
后面发现这是触发开继电器的条件,并不能控制关 :dizzy:

kjjuhfv 发表于 2024-2-24 15:27:57

大概这样?

binary_sensor:
- platform: gpio
    pin:
      number: 14
      mode: INPUT_PULLUP
    name: "SWITCHguodao"
    id: kaiguan
    on_state:
      - if:
          condition:
            and:
            - binary_sensor.is_on: pir501
            - binary_sensor.is_on: kaiguan
          then:
            - binary_sensor.template.publish:
                  id: trigger
                  state: on
          else:
            - binary_sensor.template.publish:
                  id: trigger
                  state: off

- platform: gpio
    pin:
      number: 12
      mode: INPUT_PULLUP
    name: "erlouganyingqi"
    device_class: motion
    id: pir501
    filters:
      - delayed_on: 800ms
      - delayed_off: 5s      
      on_press:
      then:
      - if:
            condition:
            and:
                - binary_sensor.is_on: pir501
            then:
            - logger.log: "Detected somebody activity"
            - binary_sensor.template.publish:
                  id: trigger
                  state: on
            else:
            - logger.log: "There is no one around"
            - binary_sensor.template.publish:
                  id: trigger
                  state: on
    on_release:                           
      then:
      - switch.turn_off: relay

- platform: template
    name: "Infrared sensor"
    id: trigger
    device_class: motion
    on_press:
      - switch.turn_off: relay
      - delayed_off: 10s
    on_release:                           
      - switch.turn_off: relay

switch:
- platform: gpio
    name: "SWITCHguodao"
    pin: GPIO4
    id: relay



Awe7 发表于 2024-2-24 16:07:44

kjjuhfv 发表于 2024-2-24 15:27
大概这样?

INFO ESPHome 2024.2.0
INFO Reading configuration /config/esphome/32.yaml...
ERROR Error while reading config: Invalid YAML syntax:

while parsing a block collection
in "/config/esphome/32.yaml", line 61, column 7
expected <block end>, but found '?'
in "/config/esphome/32.yaml", line 63, column 7
报错0.0
页: [1] 2
查看完整版本: 求个esphome配置文件