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

 找回密码
 立即注册
查看: 5693|回复: 12

新人第一帖,关于自动化感应灯分享及讨论

[复制链接]

2

主题

143

帖子

884

积分

高级会员

Rank: 4

积分
884
金钱
741
HASS币
0
发表于 2017-11-28 18:28:10 | 显示全部楼层 |阅读模式
本帖最后由 metoo 于 2017-11-28 19:33 编辑

之前用的domoticz,自动化相对来说比较简单
但是hass界面好看啊
最近研究了一段时间,想实现以下效果
有人时而且亮度低则开灯,亮度高关灯,亮度低人还在则开灯.人走后15秒关灯
前面3条都实现了,就是最后一条还不完美.
最后一条目前已知的问题有:
人走了15秒内又回来,灯还是15秒关闭.
已经结局,感谢管理员,代码在7楼

#玄关人体感应灯
- alias: auto_xuanguan_light_1 
  initial_state: true
  hide_entity: true
  trigger: 
    - platform: state
      entity_id: binary_sensor.xuanguanpir
      from: 'off'
      to: 'on'
  condition:
    condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.ketinglux
        below: 5
      - condition: state
        entity_id: switch.sonoffxuanguan
        state: 'off'
  action:
    - service: switch.turn_on
      entity_id: switch.sonoffxuanguan

- alias: auto_xuanguan_light_on_2
  initial_state: true
  hide_entity: true
  trigger: 
    - platform: numeric_state
      entity_id: sensor.ketinglux
      below: 5
  condition:
    condition: and
    conditions:
     - condition: state
       entity_id: switch.sonoffxuanguan
       state: 'off'
     - condition: state
       entity_id: binary_sensor.xuanguanpir
       state: 'on'
  action:
    - service: switch.turn_on
      entity_id: switch.sonoffxuanguan

- alias: auto_xuanguan_light_off_1
  initial_state: true
  hide_entity: true
  trigger: 
    - platform: state
      entity_id: binary_sensor.xuanguanpir
      from: 'on'
      to: 'off'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: switch.sonoffxuanguan
        state: 'on'
      - condition: state
        entity_id: binary_sensor.xuanguanpir
        state: 'off'
  action:
    - delay:
       seconds: 15
    - service: switch.turn_off
      entity_id: switch.sonoffxuanguan

- alias: auto_xuanguan_light_off_2
  initial_state: true
  hide_entity: true
  trigger: 
    - platform: numeric_state
      entity_id: sensor.ketinglux
      above: 10
  condition:
    - condition: state
      entity_id: switch.sonoffxuanguan
      state: 'on'
  action:
    - service: switch.turn_off
      entity_id: switch.sonoffxuanguan
回复

使用道具 举报

2

主题

143

帖子

884

积分

高级会员

Rank: 4

积分
884
金钱
741
HASS币
0
 楼主| 发表于 2017-11-28 18:47:40 | 显示全部楼层
本帖最后由 metoo 于 2017-11-28 18:50 编辑
- alias: auto_xuanguan_light_off_1
  initial_state: true
  hide_entity: true
  trigger: 
    - platform: state
      entity_id: binary_sensor.xuanguanpir
      from: 'on'
      to: 'off'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: switch.sonoffxuanguan
        state: 'on'
      - condition: state
        entity_id: binary_sensor.xuanguanpir
        state: 'off'
  action:
    - delay:
       seconds: 15
    - service: switch.turn_off
      entity_id: switch.sonoffxuanguan


之前看到的代码都是开灯一段时间后关灯,修改了下
这一段是判断15秒关灯的代码,实现了没人才执行关灯命令,而不是到时间直接关灯但现在还不是我希望的效果
我希望的效果是在最后一次PIR没人后15秒关灯,而现在是第一次PIR没人后15秒就关灯了

回复

使用道具 举报

123

主题

4626

帖子

1万

积分

管理员

囧死

Rank: 9Rank: 9Rank: 9

积分
16013
金钱
11302
HASS币
45
发表于 2017-11-28 18:48:58 | 显示全部楼层
别用delay,单独写一个自动化,用for: 00:00:15。意思是无人状态保持15秒后,执行操作。中间人回来,会以回来后这次的状态再推迟15秒。
回复

使用道具 举报

2

主题

143

帖子

884

积分

高级会员

Rank: 4

积分
884
金钱
741
HASS币
0
 楼主| 发表于 2017-11-28 18:51:32 | 显示全部楼层
Jones 发表于 2017-11-28 18:48
别用delay,单独写一个自动化,用for: 00:00:15。意思是无人状态保持15秒后,执行操作。中间人回来,会以回 ...

抓到管理员一只!
能帮我提下权限吗?好多东西看不到~~
回复

使用道具 举报

123

主题

4626

帖子

1万

积分

管理员

囧死

Rank: 9Rank: 9Rank: 9

积分
16013
金钱
11302
HASS币
45
发表于 2017-11-28 18:53:30 | 显示全部楼层
metoo 发表于 2017-11-28 18:51
抓到管理员一只!
能帮我提下权限吗?好多东西看不到~~

两周临时权限已提,希望学到东西后交作业,转为正式权限
回复

使用道具 举报

2

主题

143

帖子

884

积分

高级会员

Rank: 4

积分
884
金钱
741
HASS币
0
 楼主| 发表于 2017-11-28 19:06:15 | 显示全部楼层
Jones 发表于 2017-11-28 18:53
两周临时权限已提,希望学到东西后交作业,转为正式权限

一定好好学习,天天向上
回复

使用道具 举报

2

主题

143

帖子

884

积分

高级会员

Rank: 4

积分
884
金钱
741
HASS币
0
 楼主| 发表于 2017-11-28 19:30:19 | 显示全部楼层
感谢管理员大大,已经完美结局啦!
代码如下

- alias: auto_xuanguan_light_off_1
  initial_state: true
  hide_entity: true
  trigger: 
    - platform: state
      entity_id: binary_sensor.xuanguanpir
      from: 'on'
      to: 'off'
      for: 00:00:15
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: switch.sonoffxuanguan
        state: 'on'
      - condition: state
        entity_id: binary_sensor.xuanguanpir
        state: 'off'
  action:
    - service: switch.turn_off
      entity_id: switch.sonoffxuanguan
回复

使用道具 举报

4

主题

112

帖子

2049

积分

金牌会员

Rank: 6Rank: 6

积分
2049
金钱
1937
HASS币
0
发表于 2017-11-28 22:25:11 | 显示全部楼层
感谢楼主,学习了,自动化还有好多语法不会用。
回复

使用道具 举报

0

主题

41

帖子

273

积分

中级会员

Rank: 3Rank: 3

积分
273
金钱
232
HASS币
0
发表于 2017-11-30 23:11:14 | 显示全部楼层
看来要好好学习,新手入门,什么都看不懂
回复

使用道具 举报

1

主题

19

帖子

64

积分

注册会员

Rank: 2

积分
64
金钱
45
HASS币
0
发表于 2017-12-1 20:38:33 | 显示全部楼层
谢谢楼主分享
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-24 04:36 , Processed in 0.248665 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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