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

 找回密码
 立即注册
楼主: 情非殇

[新奇玩法] 易用版-延迟倒计时的通用定时器卡片

  [复制链接]

1

主题

23

帖子

404

积分

中级会员

Rank: 3Rank: 3

积分
404
金钱
381
HASS币
0
发表于 2022-12-8 10:48:03 | 显示全部楼层
看看。学习下
回复

使用道具 举报

6

主题

73

帖子

1450

积分

金牌会员

Rank: 6Rank: 6

积分
1450
金钱
1377
HASS币
0
发表于 2022-12-9 13:22:22 | 显示全部楼层
谢谢分享
回复

使用道具 举报

0

主题

30

帖子

308

积分

中级会员

Rank: 3Rank: 3

积分
308
金钱
278
HASS币
0
发表于 2023-2-1 15:16:18 | 显示全部楼层
感谢分享
回复

使用道具 举报

0

主题

1

帖子

34

积分

新手上路

Rank: 1

积分
34
金钱
33
HASS币
0
发表于 2023-2-6 22:15:05 | 显示全部楼层
感谢
回复

使用道具 举报

0

主题

33

帖子

374

积分

中级会员

Rank: 3Rank: 3

积分
374
金钱
341
HASS币
0
发表于 2023-2-6 23:11:13 | 显示全部楼层
必须支持一下
回复

使用道具 举报

0

主题

6

帖子

62

积分

注册会员

Rank: 2

积分
62
金钱
56
HASS币
0
发表于 2023-2-13 11:51:49 | 显示全部楼层
版-延迟倒计时的通用定时器卡片
回复

使用道具 举报

10

主题

145

帖子

1619

积分

论坛技术达人

积分
1619
金钱
1469
HASS币
30
发表于 2023-5-16 20:21:10 | 显示全部楼层
## 倒计时通用面板
homeassistant:
  customize:
    sensor.timer_setting:
      friendly_name: 设置延迟时间
      icon: mdi:timer
    input_number.timer_hour:
      friendly_name: 时
      icon: mdi:timer
    input_number.timer_min:
      friendly_name: 分
      icon: mdi:timer
    input_number.timer_sec:
      friendly_name: 秒
      icon: mdi:timer
      # hidden: true
    timer.timer:
      friendly_name: 延迟倒计时
      icon: mdi:timer
    script.timer_start:
      friendly_name: 开始倒计时
      icon: mdi:timer
    script.timer_cancel:
      friendly_name: 取消倒计时
      icon: mdi:timer-off
    

input_select:
  timer_climate:
    name: 延时关闭空调
    options:
      - 选择空调
      - 客厅空调
      - 主卧空调
      - 次卧空调
      - 客卧空调
    initial: '选择空调'
    icon: mdi:format-list-checkbox #select-all #toggle-switch-off
  timer_switch:
    name: 延时关闭设备
    options:
      - 选择设备
      - 客厅大灯
      - 客厅餐灯
      - 未定义8
      - 未定义9
      - 未定义0
    initial: '选择设备'
    icon: mdi:format-list-checkbox #select-all #toggle-switch-off
  timer_state:
    name: 操作
    options:
      - 开
      - 关
    initial: '关'
    icon: mdi:light-switch #nintendo-switch

sensor:
  - platform: template
    sensors:
      timer_setting:
        friendly_name: 'Time'
        value_template: '{{ "%0.02d:%0.02d:%0.02d" | format(states("input_number.timer_hour") | int, states("input_number.timer_min") | int, states("input_number.timer_sec") | int) }}'

input_number:
  timer_hour:
    name: TimerHour
    # icon: mdi:timer
    # initial: 00
    min: 0
    max: 23
    step: 1
  timer_min:
    name: TimerMinute
    # icon: mdi:timer
    # initial: 00
    min: 0
    max: 59
    step: 1
  timer_sec:
    name: TimerSecond
    # icon: mdi:timer
    initial: 00
    min: 0
    max: 59
    step: 1

timer:
  timer:
    duration: '00:00:00'

script:
  timer_start:
    sequence:
      service: timer.start
      data_template: 
        entity_id: timer.timer
        duration: >
          {{ states("sensor.timer_setting") }}  
  timer_cancel:
    sequence:
      service: timer.cancel
      entity_id: timer.timer

group:
  timer_switch:
    control: hidden
    name: 通用延时器
    entities:
      - input_select.timer_climate
      - input_select.timer_switch
      - input_select.timer_state
      - sensor.timer_setting
      - input_number.timer_hour
      - input_number.timer_min
      - input_number.timer_sec
      - timer.timer
      - script.timer_start
      - script.timer_cancel

# binary_sensor:
#   - platform: platform: state
#     name: timer_climate
#     entity_id: input_select.timer_climate
#     payload_on: "Select Input"
#   - platform: platform: state
#     name: timer_switch
#     entity_id: input_select.timer_switch
#     payload_on: "Select Input"

automation:
  - alias: number_timer
    hide_entity: true
    trigger:
      - platform: state
        entity_id: sensor.timer_setting
    action:
      service: timer.start
      data_template: 
        entity_id: timer.timer
        duration: >
          {{ states("sensor.timer_setting") }}
  - alias: empty_timer
    hide_entity: true
    trigger:
      - platform: state
        entity_id: input_select.timer_climate
      - platform: state
        entity_id: input_select.timer_switch
      - platform: state
        entity_id: input_select.timer_state
    action:
      - service: timer.cancel
        entity_id: timer.timer
      # - service: timer.start
      #   data_template: 
      #     entity_id: timer.timer
      #     duration: >
      #       {{ states("sensor.timer_setting") }}
  - alias: timer_climate_delay
    hide_entity: true
    trigger: 
      platform: event
      event_type: timer.finished
      event_data: 
        entity_id: timer.timer
    action: 
      - service: climate.set_operation_mode
        data_template:
          entity_id: >-
            {% if is_state("input_select.timer_climate", "客厅空调") %}
              climate.mqtt_34ea344dd13c
            {% elif is_state("input_select.timer_climate", "主卧空调") %}
              climate.mqtt_34ea3496151c
            {% elif is_state("input_select.timer_climate", "次卧空调") %}
              climate.entity_id3
            {% elif is_state("input_select.timer_climate", "客卧空调") %}
              climate.entity_id4
            {% endif %}
          operation_mode: '关闭'
      - service: input_select.select_option
        data:
          entity_id: input_select.timer_climate
          option: "选择空调"
  - alias: timer_switch_turnon
    hide_entity: true
    trigger:
      platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.timer
    condition:
      condition: state
      entity_id: input_select.timer_state
      state: '开'    
    action:
      - service: homeassistant.turn_on
        data_template:
          entity_id: >-
            {% if is_state("input_select.timer_switch", "客厅大灯") %}
              light.fsl002_cloud_646808
            {% elif is_state("input_select.timer_switch", "客厅餐灯") %}
              light.wy0b01_cloud_056917
            {% elif is_state("input_select.timer_switch", "未定义8") %}
              switch.entity_id8
            {% elif is_state("input_select.timer_switch", "未定义9") %}
              switch.entity_id9
            {% elif is_state("input_select.timer_switch", "未定义0") %}
              switch.entity_id0
            {% endif %}
      - service: input_select.select_option
        data:
          entity_id: input_select.timer_switch
          option: "选择设备"
  - alias: timer_switch_turnoff
    hide_entity: true
    trigger:
      platform: event
      event_type: timer.finished
      event_data:
        entity_id: timer.timer
    condition:
      condition: state
      entity_id: input_select.timer_state
      state: '关'         
    action:
      - service: homeassistant.turn_off
        data_template:
          entity_id: >-
            {% if is_state("input_select.timer_switch", "客厅大灯") %}
              light.fsl002_cloud_646808
            {% elif is_state("input_select.timer_switch", "客厅餐灯") %}
              light.wy0b01_cloud_056917
            {% elif is_state("input_select.timer_switch", "未定义8") %}
              switch.entity_id8
            {% elif is_state("input_select.timer_switch", "未定义9") %}
              switch.entity_id9
            {% elif is_state("input_select.timer_switch", "未定义0") %}
              switch.entity_id0
            {% endif %}
      - service: input_select.select_option
        data:
          entity_id: input_select.timer_switch
          option: "选择设备"


请有代码有什么错误,显示组错误
回复

使用道具 举报

0

主题

37

帖子

532

积分

高级会员

Rank: 4

积分
532
金钱
495
HASS币
0
发表于 2023-5-16 23:00:43 | 显示全部楼层
谢谢分享
回复

使用道具 举报

27

主题

2143

帖子

8930

积分

论坛元老

Rank: 8Rank: 8

积分
8930
金钱
6782
HASS币
30

论坛元老

 楼主| 发表于 2023-5-17 10:18:26 | 显示全部楼层
hunl1986 发表于 2023-5-16 20:21
请有代码有什么错误,显示组错误

group部分要删掉,hass早期版本是靠group代码去做分组的,现在都是lovelace分组了
回复

使用道具 举报

10

主题

145

帖子

1619

积分

论坛技术达人

积分
1619
金钱
1469
HASS币
30
发表于 2023-5-17 10:21:19 | 显示全部楼层
情非殇 发表于 2023-5-17 10:18
group部分要删掉,hass早期版本是靠group代码去做分组的,现在都是lovelace分组了 ...

好的,多谢大神
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-23 19:49 , Processed in 0.105042 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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