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

 找回密码
 立即注册
查看: 10321|回复: 26

[技术探讨] 一个有关暖气(燃气炉)自动化控制的讨论

[复制链接]

9

主题

519

帖子

2280

积分

金牌会员

Rank: 6Rank: 6

积分
2280
金钱
1761
HASS币
0
发表于 2020-12-1 22:35:26 | 显示全部楼层 |阅读模式
我现在的代码。总感觉有点怪怪的。
希望大神们指正。
温度是小米蓝牙通过eps蓝牙网关获取的。
燃气炉开关是esp8266自己做的。
还有个问题。 若是要计算室内平均温度要怎么写?

#继电器开关10.0.0.223
switch:
  - platform: mqtt
    name: "暖气开关"
    state_topic: "stat/ranqi/POWER"
    command_topic: "cmnd/ranqi/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
    icon: mdi:power-standby
#出水温度
#sensor:  
#  - platform: mqtt
#    name: "暖气出水温度"
#    state_topic: "tele/ranqi/SENSOR"
#    value_template: "{{value_json['DS18B20'].Temperature}}"
#    unit_of_measurement: "°C"
    
##自动化
#、1平日自动化
automation:
#启动
  - alias: heater.auto_on      #低于20度启动燃气炉
    initial_state: true  ##在你重启HA的时候这个自动化是开启(true)还是关闭(false)
    #hide_entity: false  #隐藏自动化
    trigger:            #触发
      - platform: numeric_state   #数字类状态、温度低于20度
        entity_id: sensor.woshiwendu
        below: 20 
    condition:
      condition: or
      conditions:
        - condition: time #时间条件:周一到周六  16:30~5:30
          after: '16:30:00'
          before: '5:30:00'
          weekday:
            - mon #周1
            - tue #周2
            - wed #周3
            - thu #周4
            - fri #周5
            - sat #周6
        - condition: time #时间条件:周日全天
          weekday:
            - sun #周7
    action:
      service: switch.turn_on
      entity_id: switch.nuan_qi_kai_guan
#停止
  - alias: heater.auto_off      #温度高于21度停止
    initial_state: true  ##在你重启HA的时候这个自动化是开启(true)还是关闭(false)
    #hide_entity: false  #隐藏自动化
    trigger:            #触发
      - platform: numeric_state   #数字类状态、温度高于21度
        entity_id: sensor.woshiwendu
        above: 21
    condition:
      condition: or
      conditions:
        - condition: time #时间条件:周一到周六  16:30~5:30
          after: '16:30:00'
          before: '5:30:00'
          weekday:
            - mon #周1
            - tue #周2
            - wed #周3
            - thu #周4
            - fri #周5
            - sat #周6
        - condition: time #时间条件:周日全天
          weekday:
            - sun #周7
    action:
      service: switch.turn_off
      entity_id: switch.nuan_qi_kai_guan
      
      
#、2节假日在家自动化
#启动
  - alias: 2heater.auto_on      #低于20度启动燃气炉
    initial_state: false  ##在你重启HA的时候这个自动化是开启(true)还是关闭(false)
    #hide_entity: false  #隐藏自动化
    trigger:            #触发
      - platform: numeric_state   #数字类状态、温度低于20度
        entity_id: sensor.woshiwendu
        below: 20 
    action:
      service: switch.turn_on
      entity_id: switch.nuan_qi_kai_guan
#停止
  - alias: 2heater.auto_off      #高于21度启动燃气炉
    initial_state: false  ##在你重启HA的时候这个自动化是开启(true)还是关闭(false)
    #hide_entity: false  #隐藏自动化
    trigger:            #触发
      - platform: numeric_state   #数字类状态、温度高于21度
        entity_id: sensor.woshiwendu
        above: 21
    action:
      service: switch.turn_off
      entity_id: switch.nuan_qi_kai_guan
      
      
homeassistant:
  customize:
    automation.heater_auto_on:
      friendly_name: 平时启动
    automation.heater_auto_off:
      friendly_name: 平时停止
    automation.2heater_auto_on:
      friendly_name: 假日启动
    automation.2heater_auto_off:
      friendly_name: 假日停止


回复

使用道具 举报

26

主题

2096

帖子

8506

积分

论坛元老

Rank: 8Rank: 8

积分
8506
金钱
6405
HASS币
30

论坛元老

发表于 2020-12-2 11:46:28 | 显示全部楼层
(a+b)/2  用template sensor计算一下可以了吧
回复

使用道具 举报

9

主题

519

帖子

2280

积分

金牌会员

Rank: 6Rank: 6

积分
2280
金钱
1761
HASS币
0
 楼主| 发表于 2020-12-2 13:44:24 | 显示全部楼层
情非殇 发表于 2020-12-2 11:46
(a+b)/2  用template sensor计算一下可以了吧

我这个还有个问题没解决。。。若是在凌晨4点启动了。温度一直没达到。。那么5:30自动化结束了。就永远不能停止了。。。
求思路
回复

使用道具 举报

0

主题

91

帖子

1497

积分

金牌会员

Rank: 6Rank: 6

积分
1497
金钱
1406
HASS币
0
发表于 2020-12-2 14:31:17 | 显示全部楼层
是追求完全用ESPHome实现吗?
个人用HA的Generic Thermostat实现感觉更容易。。。
回复

使用道具 举报

26

主题

2096

帖子

8506

积分

论坛元老

Rank: 8Rank: 8

积分
8506
金钱
6405
HASS币
30

论坛元老

发表于 2020-12-2 16:15:34 | 显示全部楼层
yylwhy 发表于 2020-12-2 13:44
我这个还有个问题没解决。。。若是在凌晨4点启动了。温度一直没达到。。那么5:30自动化结束了。就永远不 ...

轮询呀,2个自动化,
1)a自动化,4点,触发,执行打开b自动化automation,5点半关闭b自动化
2)b自动化,轮询,每几分钟触发一次,condition是判断温度,action执行你要搞的东西
回复

使用道具 举报

9

主题

519

帖子

2280

积分

金牌会员

Rank: 6Rank: 6

积分
2280
金钱
1761
HASS币
0
 楼主| 发表于 2020-12-2 20:07:38 | 显示全部楼层
情非殇 发表于 2020-12-2 16:15
轮询呀,2个自动化,
1)a自动化,4点,触发,执行打开b自动化automation,5点半关闭b自动化
2)b自动化 ...

多谢指点。。。还没消化
回复

使用道具 举报

9

主题

519

帖子

2280

积分

金牌会员

Rank: 6Rank: 6

积分
2280
金钱
1761
HASS币
0
 楼主| 发表于 2020-12-2 20:16:28 | 显示全部楼层
hellkun 发表于 2020-12-2 14:31
是追求完全用ESPHome实现吗?
个人用HA的Generic Thermostat实现感觉更容易。。。 ...

这个ha里面的。
Generic Thermostat  这个是什么?
回复

使用道具 举报

17

主题

760

帖子

5274

积分

论坛元老

Rank: 8Rank: 8

积分
5274
金钱
4509
HASS币
0
发表于 2020-12-2 21:09:11 | 显示全部楼层
基本还是每分钟判断就好了。低了就开高了就关。区间看自己习惯,我是前后0.5度。
需要多个传感器就加起来除一下再round(1)一下。

无标题.png
回复

使用道具 举报

6

主题

737

帖子

5582

积分

论坛元老

Rank: 8Rank: 8

积分
5582
金钱
4840
HASS币
20
发表于 2020-12-2 21:15:49 | 显示全部楼层
平均温度可以min-max传感器,类型设置成mean就行了
# 家里平均温度
- platform: min_max
  name: "temperature_average"
  type: "mean"
  round_digits: 1
  entity_ids:
    - sensor.a_temperature
    - sensor.b_temperature
    - sensor.c_temperature
温度控制,建议采用generic_thermostat
参看:
https://www.home-assistant.io/integrations/min_max/
https://www.home-assistant.io/integrations/generic_thermostat/

评分

参与人数 1金钱 +1 收起 理由
yylwhy + 1 论坛有你更精彩!

查看全部评分

回复

使用道具 举报

14

主题

654

帖子

3826

积分

论坛元老

Rank: 8Rank: 8

积分
3826
金钱
3167
HASS币
10
发表于 2020-12-2 22:42:00 | 显示全部楼层
hellkun 发表于 2020-12-2 14:31
是追求完全用ESPHome实现吗?
个人用HA的Generic Thermostat实现感觉更容易。。。 ...

这个好,我也在用 我觉得不错
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-4-25 05:18 , Processed in 0.269808 second(s), 36 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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