『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 1551|回复: 5

[技术探讨] ESPHOME 接收433信号设置为点动开关

[复制链接]

26

主题

169

帖子

652

积分

高级会员

Rank: 4

积分
652
金钱
483
HASS币
0
发表于 2022-1-4 02:33:02 | 显示全部楼层 |阅读模式
请问怎样修改这个代码为按一下遥控器   传感器状态 变为开启后 1秒后自动变回关闭状态?
现在的状态是按一下遥控器 开启,再按一下遥控器 才关闭。这样子不好做自动化。

请求各位帮个忙修改下。谢谢


remote_receiver:
  pin: GPIO2
  dump:
    - rc_switch
  tolerance: 50%
  filter: 250us
  idle: 4ms
  buffer_size: 2kb


binary_sensor:


# 1  433遥控器


  - platform: template
    name: "433button"
    id: a433button
  - platform: remote_receiver
    name: "433button"
    internal: true
    rc_switch_raw:
      code: "000111011110010110001010"
      protocol: 1
    filters:
      delayed_off: 100ms  
    on_press:
      if:
        condition:
          binary_sensor.is_on: a433button  
        then:
          - binary_sensor.template.publish:
              id: a433button
              state: OFF
        else:
          - binary_sensor.template.publish:
              id: a433button
              state: ON
              
2.png screenshot.png

回复

使用道具 举报

30

主题

526

帖子

2333

积分

金牌会员

Rank: 6Rank: 6

积分
2333
金钱
1802
HASS币
20
发表于 2022-1-4 07:46:21 | 显示全部楼层
我是用的写成scripts的办法 就是一个 执行 按键了 没有状态反馈
回复

使用道具 举报

43

主题

408

帖子

3645

积分

元老级技术达人

积分
3645
金钱
3232
HASS币
136
发表于 2022-1-4 12:14:27 | 显示全部楼层
dinglifeng 发表于 2022-1-4 07:46
我是用的写成scripts的办法 就是一个 执行 按键了 没有状态反馈

delay: 1s 然后关闭
回复

使用道具 举报

26

主题

169

帖子

652

积分

高级会员

Rank: 4

积分
652
金钱
483
HASS币
0
 楼主| 发表于 2022-1-4 17:11:29 来自手机 | 显示全部楼层
hunterfox 发表于 2022-1-4 12:14
delay: 1s 然后关闭

请问怎样修改?谢谢
回复

使用道具 举报

12

主题

178

帖子

1283

积分

金牌会员

Rank: 6Rank: 6

积分
1283
金钱
1100
HASS币
20
发表于 2022-1-4 17:20:57 | 显示全部楼层
本帖最后由 mildrabbit 于 2022-1-4 17:23 编辑

esphome:
  name: dswitch_computer
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: " "
  password: " "
  fast_connect: True
  use_address: 10.0.0.30  # 指定烧录固件时候目标设备IP,优先级高于静态IP
  
  manual_ip:
    static_ip:
    gateway:
    subnet:
    dns1:
    dns2:
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Dswitch Computer"
    password: " "

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

web_server:
  port: 80
  auth:
    username: admin
    password: ''

switch:
  - platform: gpio
    pin: 14
    id: relay
    inverted: true
   
  - platform: template
    name: "PWR"
    icon: "mdi:computer"
    turn_on_action:
    - switch.turn_on: relay
    - delay: 500ms            # 打开后延时500ms后设置为关  
    - switch.turn_off: relay
   

  - platform: gpio
    pin: 16
    id: relay2
    inverted: true
   
  - platform: template
    name: "RST"
    icon: "mdi:computer"
    turn_on_action:
    - switch.turn_on: relay2
    - delay: 500ms
    - switch.turn_off: relay2


binary_sensor:
  - platform: gpio
    pin:
      number: GPIO4
      inverted: false
      mode: INPUT_PULLUP
    name: "Study Computer"
    device_class: power

这个可以参考下。
回复

使用道具 举报

26

主题

169

帖子

652

积分

高级会员

Rank: 4

积分
652
金钱
483
HASS币
0
 楼主| 发表于 2022-1-4 23:32:45 来自手机 | 显示全部楼层
mildrabbit 发表于 2022-1-4 17:20
esphome:
  name: dswitch_computer
  platform: ESP8266

你这代码是开关代码自动复位是没问题,但传感器不适用这代码。
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-14 02:22 , Processed in 0.165010 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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