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

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

[求助] 【已解决】求助,想咨询个DC1的自动化

[复制链接]

2

主题

47

帖子

266

积分

论坛积极会员

积分
266
金钱
219
HASS币
0
发表于 2019-2-8 12:10:32 | 显示全部楼层 |阅读模式
本帖最后由 番茄鸡蛋面 于 2019-2-12 17:04 编辑

插座口1 电脑主机
插座口2 显示器
插座口3 音响

当电脑打开 功率是大于50 W 的

想实现 电脑开机 功率大于50自动打开插座口2.3

电脑关闭  功率小于50
自动关闭插座口2.3

新手不会,在自动化看了半天没看明白,

我的dc1 配置

sensor:
  - platform: template
    sensors:
      dc1_shufang_v:
        friendly_name: 当前电压
        value_template: "{{ states.switch.dc1_shufang.attributes.v }}"
        unit_of_measurement: V
      dc1_shufang_p:
        friendly_name: 当前功率
        value_template: "{{ states.switch.dc1_shufang.attributes.p }}"
        unit_of_measurement: W




group:
  dc1_shufang:
    name: 书房DC1排插
    view: false
    entities:
      - sensor.dc1_shufang_v
      - sensor.dc1_shufang_p
      - sensor.dc1_shufang_totale
      - switch.dc1_shufang
      - switch.dc1_shufang_s1
      - switch.dc1_shufang_s2
      - switch.dc1_shufang_s3

homeassistant:        
  customize:
    switch.dc1_shufang:
      friendly_name: 书房插座
    switch.dc1_shufang_s1:
      friendly_name: 电脑
    switch.dc1_shufang_s2:
      friendly_name: 显示器
    switch.dc1_shufang_s3:
      friendly_name: 音响


麻烦会的大佬帮忙写一个简单的自动化,这样下次自己就可以依葫芦画瓢了。


回复

使用道具 举报

26

主题

2096

帖子

8508

积分

论坛元老

Rank: 8Rank: 8

积分
8508
金钱
6407
HASS币
30

论坛元老

发表于 2019-2-8 16:55:25 | 显示全部楼层
本帖最后由 情非殇 于 2019-2-8 17:04 编辑
#自动化配置
automation:
  - alias: test1_dc1
    trigger: 
      platform: numeric_state
      entity_id: switch.dc1_shufang
      value_template: '{{ state.attributes.p }}'
      above: 50       ##功率高于50
      for:
        seconds: 2    ##等待2秒
    condition:
      ## 如果2或者3是关闭状态
      condition: or
      conditions:
        - condition: state
          entity_id: switch.dc1_shufang_s3
          state: 'off'
        - condition: state
          entity_id: switch.dc1_shufang_s3
          state: 'off'
    action:
      ## 打开2和3开关
      ervice: switch.turn_on
      entity_id:
        - switch.dc1_shufang_s2
        - switch.dc1_shufang_s3
  - alias: test2_dc1
    trigger: 
      platform: numeric_state
      entity_id: switch.dc1_shufang
      value_template: '{{ state.attributes.p }}'
      below: 50       ##功率低于50
      for:
        seconds: 2    ##等待2秒
    condition:
      ## 如果2或者3是打开状态
      condition: or
      conditions:
        - condition: state
          entity_id: switch.dc1_shufang_s3
          state: 'on'
        - condition: state
          entity_id: switch.dc1_shufang_s3
          state: 'on'
    action:
      ## 关闭2和3开关
      ervice: switch.turn_off
      entity_id:
        - switch.dc1_shufang_s2
        - switch.dc1_shufang_s3
回复

使用道具 举报

2

主题

47

帖子

266

积分

论坛积极会员

积分
266
金钱
219
HASS币
0
 楼主| 发表于 2019-2-8 20:56:27 | 显示全部楼层
情非殇 发表于 2019-2-8 16:55
[code]#自动化配置
automation:
  - alias: test1_dc1

谢谢大佬。我试试。
回复

使用道具 举报

2

主题

47

帖子

266

积分

论坛积极会员

积分
266
金钱
219
HASS币
0
 楼主| 发表于 2019-2-9 00:11:27 | 显示全部楼层
[quote]情非殇 发表于 2019-2-8 16:55
#自动化配置
automation:
  - alias: test1_dc1
[/quote]不行大佬,
你看这是我在自动化自己添加的,
问题是打开所有的开关,把所有关着的开关都打开了,怎么才能固定只让打开固定开关
[code]- id: '1549641492615'
  alias: 打开音响
  trigger:
  - above: '50'
    entity_id: sensor.dc1_shufang_p
    platform: numeric_state
  condition: []
  action:
    service: switch.turn_on
    entity_id:
      - switch.dc1_shufang_s2
      - switch.dc1_shufang_s3

回复

使用道具 举报

26

主题

2096

帖子

8508

积分

论坛元老

Rank: 8Rank: 8

积分
8508
金钱
6407
HASS币
30

论坛元老

发表于 2019-2-9 14:53:18 | 显示全部楼层
番茄鸡蛋面 发表于 2019-2-9 00:11
不行大佬,
你看这是我在自动化自己添加的,
问题是打开所有的开关,把所有关着的开关都打开了,怎么才能 ...

帮不了你,你自己瞎鸡巴改,我知道你哪里问题
回复

使用道具 举报

2

主题

47

帖子

266

积分

论坛积极会员

积分
266
金钱
219
HASS币
0
 楼主| 发表于 2019-2-11 23:02:11 | 显示全部楼层
情非殇 发表于 2019-2-9 14:53
帮不了你,你自己瞎鸡巴改,我知道你哪里问题

谢谢 研究好了,照着你这终于画葫芦添加好了,估计我的版本问题,。
- id: '1549896506913'
  alias: 音响
  trigger:
  - above: '50'
    entity_id: sensor.dc1_shufang_v
    platform: numeric_state
  condition:
  - condition: state
    entity_id: switch.dc1_shufang_s3
    state: 'off'
  action:
  - entity_id: switch.dc1_shufang_s3
    service: switch.turn_on


entity_id 必须在上面,要不就打开我所有的开关了~
回复

使用道具 举报

2

主题

47

帖子

266

积分

论坛积极会员

积分
266
金钱
219
HASS币
0
 楼主| 发表于 2019-2-11 23:28:24 | 显示全部楼层
情非殇 发表于 2019-2-9 14:53
帮不了你,你自己瞎鸡巴改,我知道你哪里问题
- id: '1549898280486'
  alias: 打开音响显示器
  trigger:
  - above: '50'
    entity_id: sensor.dc1_shufang_p
    platform: numeric_state
  condition:
  - condition: state
    entity_id: switch.dc1_shufang_s2
    state: 'off'
  - condition: state
    entity_id: switch.dc1_shufang_s3
    state: 'off'
  action:
    entity_id:
    - switch.dc1_shufang_s2
    - switch.dc1_shufang_s3
    service: switch.turn_on
- id: '1549898616412'
  alias: 关闭音响显示器
  trigger:
  - below: '50'
    entity_id: sensor.dc1_shufang_p
    platform: numeric_state
  condition:
  - condition: state
    entity_id: switch.dc1_shufang_s2
    state: 'on'
  - condition: state
    entity_id: switch.dc1_shufang_s3
    state: 'on'
  action:
    entity_id:
    - switch.dc1_shufang_s2
    - switch.dc1_shufang_s3
    service: switch.turn_off


大佬你看
回复

使用道具 举报

26

主题

2096

帖子

8508

积分

论坛元老

Rank: 8Rank: 8

积分
8508
金钱
6407
HASS币
30

论坛元老

发表于 2019-2-12 09:03:57 | 显示全部楼层
番茄鸡蛋面 发表于 2019-2-11 23:28
[code]- id: '1549898280486'
  alias: 打开音响显示器
  trigger:

1)我都是以官网实例为准的
2)为什么你把行顺序都改了,我不知道有没有影响
2)id是什么东西,官方文档没有这种写法,我不知道有没有影响
3)entity_id下面是有2个缩进的,你为什么改了,应该是这里的问题,这里是指定下面的2个设备生效的,如果没有指定设备,就变成了对全局switch生效而且各个项目的缩进你都改的乱七八糟的,你这样,真的是懒得帮你
4)alias貌似没有直接中文的写法,我记不太清了
回复

使用道具 举报

2

主题

47

帖子

266

积分

论坛积极会员

积分
266
金钱
219
HASS币
0
 楼主| 发表于 2019-2-12 17:03:56 | 显示全部楼层
情非殇 发表于 2019-2-12 09:03
1)我都是以官网实例为准的
2)为什么你把行顺序都改了,我不知道有没有影响
2)id是什么东西,官方文档没 ...

我是在自动化中加的,我按照你的写进去不能用,就一条一条对着自动化写着,最后发现顺序有变化,现在正常使用了,
回复

使用道具 举报

26

主题

2096

帖子

8508

积分

论坛元老

Rank: 8Rank: 8

积分
8508
金钱
6407
HASS币
30

论坛元老

发表于 2019-2-12 17:24:14 | 显示全部楼层
番茄鸡蛋面 发表于 2019-2-12 17:03
我是在自动化中加的,我按照你的写进去不能用,就一条一条对着自动化写着,最后发现顺序有变化,现在正常 ...

只可能是缩进的问题,不可能是行顺序的问题,我这是官网写法,话说我还真不知道行序变了竟然不影响
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-25 10:23 , Processed in 0.081513 second(s), 32 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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