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

 找回密码
 立即注册
123
返回列表 发新帖
楼主: komazhou

[技术探讨] 【求助】空调伴侣与温湿度计的自动化配置

[复制链接]

27

主题

228

帖子

1765

积分

金牌会员

Rank: 6Rank: 6

积分
1765
金钱
1537
HASS币
0
发表于 2024-9-11 14:38:25 | 显示全部楼层
本帖最后由 huyifanstar 于 2024-9-11 14:40 编辑
komazhou 发表于 2024-9-11 13:29
再请教一下,您这个流程是按照什么来触发呢?
我目前遇到一个问题,比如我在home assistant中关闭次卧空 ...

应该还会遇到空调伴侣和红外遥控的弊端一样 都是无法存开关状态,会导致一直重复开或者关

可以试试做个辅助元素或者nr里做个全局变量 来存状态(我用mysql来存的),开/关之前判断下

回复

使用道具 举报

1

主题

35

帖子

276

积分

中级会员

Rank: 3Rank: 3

积分
276
金钱
241
HASS币
0
发表于 2024-9-11 19:31:01 | 显示全部楼层
komazhou 发表于 2024-9-11 13:29
再请教一下,您这个流程是按照什么来触发呢?
我目前遇到一个问题,比如我在home assistant中关闭次卧空 ...

1、温度计的温度每变化1个单位(我的是0.1度),则触发流程
2、判断空调是否开机,是则继续流程,否则结束流程
HA是通过miot auto以轮询的方式来跟目标实体进行通讯的(本地模式),默认周期是30秒。nodered的文档里也说了current state是轮询,但没说明周期是多少,这两个周期叠加的话是有可能更长。刚才我手动连续试了两次,一次延迟27秒(手动关空调面板,然后不断inject空调面板的current state,延迟27秒才在debug里转为off),一次延迟37秒。那么理论上似乎是存在温度计触发时空调状态尚未同步、进而错误开机的可能。但是nodered我已经用了3个月了,没有出现过一次物理关机后自动开机的现象,那么我猜测只有一种可能:nodered的轮询是早于流程的执行的,至少是current state的轮询是早于events:state的流程的执行的,自然也不可能有此种错误发生了
回复

使用道具 举报

1

主题

35

帖子

276

积分

中级会员

Rank: 3Rank: 3

积分
276
金钱
241
HASS币
0
发表于 2024-9-11 19:35:05 | 显示全部楼层
komazhou 发表于 2024-9-11 13:29
再请教一下,您这个流程是按照什么来触发呢?
我目前遇到一个问题,比如我在home assistant中关闭次卧空 ...

抱歉没注意看。

在HA里开关空调的话,相应状态是实时同步到nodered的,所以也不存在同步滞后导致错误的可能的,建议在别的方向寻找下问题吧
回复

使用道具 举报

1

主题

19

帖子

115

积分

注册会员

Rank: 2

积分
115
金钱
96
HASS币
0
 楼主| 发表于 2024-9-11 22:44:00 | 显示全部楼层
wanyevyv 发表于 2024-9-11 19:35
抱歉没注意看。

在HA里开关空调的话,相应状态是实时同步到nodered的,所以也不存在同步滞后导致错误的 ...

好的,我再看看是什么原因造成的,
回复

使用道具 举报

1

主题

35

帖子

276

积分

中级会员

Rank: 3Rank: 3

积分
276
金钱
241
HASS币
0
发表于 2024-9-12 00:01:31 | 显示全部楼层
huyifanstar 发表于 2024-9-11 14:38
应该还会遇到空调伴侣和红外遥控的弊端一样 都是无法存开关状态,会导致一直重复开或者关

可以试试做个辅 ...

明白了,谢谢提醒,原来空调伴侣是这个逻辑

我的初衷是简化家人的操作,只需开/关面板、调面板温度就行了,分析了一下楼主的应用环境,应该可以很简单就能实现,稍等我把节点贴出来
回复

使用道具 举报

1

主题

35

帖子

276

积分

中级会员

Rank: 3Rank: 3

积分
276
金钱
241
HASS币
0
发表于 2024-9-12 00:29:07 | 显示全部楼层
恕我鲁莽,确需如huyifanstar所说那样,才能实现简单的一步操作,否则只能开机+启用流程,关机+禁用流程才行
回复

使用道具 举报

1

主题

19

帖子

115

积分

注册会员

Rank: 2

积分
115
金钱
96
HASS币
0
 楼主| 发表于 2024-9-12 10:39:13 | 显示全部楼层
huyifanstar 发表于 2024-9-11 14:38
应该还会遇到空调伴侣和红外遥控的弊端一样 都是无法存开关状态,会导致一直重复开或者关

可以试试做个辅 ...

这一步有考虑,但不知道具体怎么来操作,
回复

使用道具 举报

1

主题

19

帖子

115

积分

注册会员

Rank: 2

积分
115
金钱
96
HASS币
0
 楼主| 发表于 2024-9-12 10:40:22 | 显示全部楼层
wanyevyv 发表于 2024-9-12 00:29
恕我鲁莽,确需如huyifanstar所说那样,才能实现简单的一步操作,否则只能开机+启用流程,关机+禁用流程才 ...

我现在也在观察这之中的逻辑和规律,然后再考虑具体怎么调整。谢谢各位给的帮助和建议
回复

使用道具 举报

1

主题

35

帖子

276

积分

中级会员

Rank: 3Rank: 3

积分
276
金钱
241
HASS币
0
发表于 2024-9-13 20:05:29 | 显示全部楼层
楼主试试这个吧

假设不能正确获取空调伴侣的运行状态,通过HA控制空调开关,即可实现空调伴侣的自动化。如果能正确获取空调伴侣的状态就更简单了

微信图片_20240913200043.png

[{"id":"ed2205733c30c472","type":"api-call-service","z":"0078678ef362fbed","name":"7.低速","server":"65bef38af2beb021","version":5,"debugenabled":false,"domain":"climate","service":"set_fan_mode","areaId":[],"deviceId":["5f5e92c27b29f8ff7cf8990fea565d07"],"entityId":[],"data":"{\"fan_mode\":\"low\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1210,"y":200,"wires":[[]]},{"id":"9f4ae7055d9ff9f2","type":"api-call-service","z":"0078678ef362fbed","name":"7.高速","server":"65bef38af2beb021","version":5,"debugenabled":false,"domain":"climate","service":"set_fan_mode","areaId":[],"deviceId":["5f5e92c27b29f8ff7cf8990fea565d07"],"entityId":[],"data":"{\"fan_mode\":\"high\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1210,"y":120,"wires":[[]]},{"id":"c6e42a7e162c6814","type":"server-state-changed","z":"0078678ef362fbed","name":"1.温度计温度变化则触发","server":"65bef38af2beb021","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"sensor.cgllc_s1_18dc_temperature","entityIdType":"exact","outputInitially":true,"stateType":"str","ifState":"","ifStateType":"num","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"temp","propertyType":"msg","value":"","valueType":"entityState"}],"x":130,"y":160,"wires":[["96f0b7a78aff6bc3"]]},{"id":"156f2635460bae20","type":"switch","z":"0078678ef362fbed","name":"6.可选调整风速调整阈值","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"2.6","vt":"num"},{"t":"btwn","v":"2.5","vt":"num","v2":"1.6","v2t":"num"},{"t":"lte","v":"1.5","vt":"num"}],"checkall":"true","repair":false,"outputs":3,"x":1030,"y":160,"wires":[["9f4ae7055d9ff9f2"],["c5a7b621924d6b69"],["ed2205733c30c472"]]},{"id":"c5a7b621924d6b69","type":"api-call-service","z":"0078678ef362fbed","name":"7.中速","server":"65bef38af2beb021","version":5,"debugenabled":false,"domain":"climate","service":"set_fan_mode","areaId":[],"deviceId":["5f5e92c27b29f8ff7cf8990fea565d07"],"entityId":[],"data":"{\"fan_mode\":\"medium\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1210,"y":160,"wires":[[]]},{"id":"9ec71d83428986bc","type":"api-call-service","z":"0078678ef362fbed","name":"4.空调制冷","server":"65bef38af2beb021","version":5,"debugenabled":false,"domain":"climate","service":"set_hvac_mode","areaId":[],"deviceId":["5f5e92c27b29f8ff7cf8990fea565d07"],"entityId":[],"data":"{\"hvac_mode\":\"cool\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":160,"wires":[["6e1fd118554b6fcc"]]},{"id":"c9acc0241736f515","type":"api-call-service","z":"0078678ef362fbed","name":"4.空调通风","server":"65bef38af2beb021","version":5,"debugenabled":false,"domain":"climate","service":"set_hvac_mode","areaId":[],"deviceId":["5f5e92c27b29f8ff7cf8990fea565d07"],"entityId":[],"data":"{\"hvac_mode\":\"heat\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":200,"wires":[[]]},{"id":"5f68ecbd9678cb2b","type":"switch","z":"0078678ef362fbed","name":"3.温度阈值","property":"temp","propertyType":"msg","rules":[{"t":"gte","v":"27","vt":"num"},{"t":"lte","v":"26","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":160,"wires":[["9ec71d83428986bc"],["c9acc0241736f515"]]},{"id":"f2bf1e32d825b822","type":"server-state-changed","z":"0078678ef362fbed","name":"在HA中开关空调时触发","server":"65bef38af2beb021","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"climate.cubee_th125t_2a73_thermostat","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"off","ifStateType":"str","ifStateOperator":"is_not","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":120,"y":340,"wires":[["c2f16347439e5765"],["a7da5a367b2783ee"]]},{"id":"c2f16347439e5765","type":"change","z":"0078678ef362fbed","name":"流程变量赋值on","rules":[{"t":"set","p":"woshikongtiao","pt":"flow","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":320,"wires":[[]]},{"id":"a7da5a367b2783ee","type":"change","z":"0078678ef362fbed","name":"流程变量赋值off","rules":[{"t":"set","p":"woshikongtiao","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":360,"wires":[[]]},{"id":"96f0b7a78aff6bc3","type":"switch","z":"0078678ef362fbed","name":"2.通过流程变量判断是否开机","property":"woshikongtiao","propertyType":"flow","rules":[{"t":"neq","v":"off","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":300,"y":200,"wires":[[],["5f68ecbd9678cb2b"]]},{"id":"6e1fd118554b6fcc","type":"function","z":"0078678ef362fbed","name":"5.计算温差","func":"msg.payload = (msg.temp) - 24\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":810,"y":160,"wires":[["156f2635460bae20"]]},{"id":"426bb514abeaaaef","type":"comment","z":"0078678ef362fbed","name":"修改温度计实体","info":"","x":100,"y":120,"wires":[]},{"id":"30385ed30d76ab4a","type":"comment","z":"0078678ef362fbed","name":"如在流程里部署多个空调则需修改变量名","info":"","x":340,"y":240,"wires":[]},{"id":"66ad851034379f83","type":"comment","z":"0078678ef362fbed","name":"修改空调伴侣设备","info":"","x":670,"y":240,"wires":[]},{"id":"9cc4f3c642fc77b5","type":"comment","z":"0078678ef362fbed","name":"自己设置空调制冷启停的阈值","info":"","x":540,"y":120,"wires":[]},{"id":"a15848f65da34882","type":"comment","z":"0078678ef362fbed","name":"应与第3节点的低值相同","info":"","x":840,"y":120,"wires":[]},{"id":"8fc9685a2142df6f","type":"comment","z":"0078678ef362fbed","name":"5、6、7节点是实现自动调节风速功能,如无需此功能可删除","info":"","x":960,"y":80,"wires":[]},{"id":"c28f2c4640a5b0a3","type":"comment","z":"0078678ef362fbed","name":"修改空调伴侣实体","info":"","x":110,"y":300,"wires":[]},{"id":"2f491f71a8927bde","type":"comment","z":"0078678ef362fbed","name":"修改空调伴侣设备","info":"","x":1250,"y":260,"wires":[]},{"id":"65bef38af2beb021","type":"server","name":"Home Assistant","version":5,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":": ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"default","statusTimeFormat":"h:m","enableGlobalContextStore":false}]


回复

使用道具 举报

1

主题

19

帖子

115

积分

注册会员

Rank: 2

积分
115
金钱
96
HASS币
0
 楼主| 发表于 2024-9-13 23:48:25 | 显示全部楼层
wanyevyv 发表于 2024-9-13 20:05
楼主试试这个吧

假设不能正确获取空调伴侣的运行状态,通过HA控制空调开关,即可实现空调伴侣的自动化。如 ...

非常感谢,我明天试试
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-23 22:50 , Processed in 0.309401 second(s), 32 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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