|
本帖最后由 chengka3463 于 2019-8-26 20:58 编辑
在各位大佬的帖子学习下,属于个人需求的拼凑帖子。
本贴前置条件:home assistant 已设置好mqtt、nodered;
按“笔尖”发的帖子:https://bbs.hassbian.com/forum.php?mod=viewthread&tid=7976获取红外码;
已配置packages。
贴上我的eps32固件yaml
esphome:
name: esp32
platform: ESP32
board: nodemcu-32s
wifi:
ssid: "###"
password: "#####"
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
esp32_ble_client:
sensor:
- platform: meizu_ble
update_interval: 360s
mac_address: 68:3w:35:cd:e6:28 # 蓝牙 mac地址 小写
temperature:
name: "bedroom Temperature"
humidity:
name: "bedroom Humidity"
battery_level:
name: "bedroom Battery"
switch:
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "2400"
uid: "7c001caa61c5e07648"
data: "54007c200064000001ed00ab00a70016003c00160013001600c600161f0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121122122122112112111111212222222122222212111111301211221221221121121111112122222221222222121111114"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "1000"
uid: "95001c56f5245c7648"
data: "5400952000960000018100ab00a70016003c00160013001600c600161f080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012112212212211212111121112222122111222222221111130121122122122112121111211122221221112222222211111301211221221221121222212221111211122222111111112224"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "strong"
uid: "7c001c9349ba6e7548"
data: "54007c200064000001ee00ab00a70016003c00160013001600c600161f0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121121212122121211112121222212121212221221211121301211212121221212111121212222121212122212212111214"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "show"
uid: "7c001ccbdb7c607548"
data: "54007c200064000001bd00ab00a70016003c00160013001600c600161f0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121121212122121211112121222212121212212121211212301211212121221212111121212222121212122121212112124"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "2700"
uid: "7c001cd8660c207548"
data: "54007c2000640000019c00ab00a70016003c00160013001600c600161f0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121122122122112112111111212222221221222221121111301211221221221121121111112122222212212222211211114"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "2600"
uid: "7c001c70297e8f7548"
data: "54007c2000640000014400ab00a70016003c00160013001600c600161f0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121122122122112112111111212222221121222222121111301211221221221121121111112122222211212222221211114"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "2300"
uid: "5d001c45a8dc327548"
data: "54005d2000260000011500ab00a70016003c001600130012004000041f08000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001211221221221121121111112122222221234"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "2200"
uid: "7c001c521b6f047548"
data: "54007c2000640000011700ab00a70016003c00160013001600c600161f0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121122122122112112111111212222222111222212221111301211221221221121121111112122222221112222122211114"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "2100"
uid: "7c001ca0fc4a187548"
data: "54007c2000640000016c00ab00a70016003c00160013001600c600161f0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121122122122112112111111212222222112222212211111301211221221221121121111112122222221122222122111114"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "2000"
uid: "7c001ce164343d7548"
data: "54007c200064000001b400ab00a70016003c00160013001600c600161f0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121122122122112112111111212222222212222211211111301211221221221121121111112122222222122222112111114"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "2500"
uid: "7c001c92d1529f7548"
data: "54007c200064000001ee00ab00a70016003c00160013001600c600161f0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121122122122112112211111211222221122222222111111301211221221221121122111112112222211222222221111114"
- platform: meizu_ble_transmitter
mac_address: 68:3w:35:cd:e6:28
name: "2800"
uid: "7c001cf8643d2d7548"
data: "54007c2000640000013600ab00a70016003c00160013001600c600161f0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121122122122112112211111211222221222222221111111301211221221221121122111112112222212222222211111114"
说明一下学码的命名规律:
前两位为温度,后两位为预留。比如以后可设置风速(自动:00;小风:01;中风:02;大风:03)例如:
24度自动风速:2400
24度小风:2401
18度大风:1803
关机红外码:1000
个人比较懒,就学习了制冷自动风速的红外码,常用的20到28;空调红外码是一个状态一个码,多一种模式就是翻倍的学码量。
空调控制器 Yaml
climate:
- platform: mqtt
name: bedgroom
initial: 24
min_temp: 20
max_temp: 28
modes: ["off", "cool"] # 可按官方说明添加其他选项,学码量相应翻倍
mode_command_topic: "myHASS/bedgroom/ac/mode/set"
temperature_command_topic: "myHASS/bedgroom/ac/temperature/set"
current_temperature_topic: "myHASS/bedgroom/ac/temperature/state"
swing_modes: ["数显", "强劲"] #这是个人空调数显和强劲功能按键,绕下弯,添加到了摆页的模式选项
swing_mode_command_topic: "myHASS/bedgroom/ac/swing_mode/set"
script:
ac_meizu:
sequence:
- service: switch.turn_on
data_template:
entity_id: >
{% if is_state('climate.bedgroom', 'off') %}switch.1000
{% else %}switch.{{ state_attr('climate.bedgroom','temperature') | int }}00
{% endif %}
mqtt_room_temperature: # 在室溫有變化時, 透過脚本 public 至 MQTT
sequence:
- service: mqtt.publish
data_template:
topic: myHASS/bedgroom/ac/temperature/state
payload_template: '{{states("sensor.bedroom_temperature")}}'
自动化控制是通过nodered实现的,比较简单傻瓜
[{"id":"b04250e9.7e212","type":"tab","label":"流程2","disabled":false,"info":""},{"id":"8329bb9c.339b18","type":"api-call-service","z":"b04250e9.7e212","name":"","server":"475c60b.75d4fa","version":1,"service_domain":"script","service":"ac_meizu","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":895,"y":180,"wires":[[]],"l":false},{"id":"e97c98d9.55a5a8","type":"api-call-service","z":"b04250e9.7e212","name":"","server":"475c60b.75d4fa","version":1,"service_domain":"script","service":"mqtt_room_temperature","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":675,"y":360,"wires":[[]],"l":false},{"id":"f5556435.d1a1c8","type":"server-state-changed","z":"b04250e9.7e212","name":"","server":"475c60b.75d4fa","version":1,"entityidfilter":"sensor.bedroom_temperature","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":435,"y":360,"wires":[["e97c98d9.55a5a8"]],"l":false},{"id":"c8e9c5a9.b78508","type":"api-current-state","z":"b04250e9.7e212","name":"","server":"475c60b.75d4fa","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"climate.bedgroom","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":675,"y":120,"wires":[["a3bb573c.6c1538"]],"l":false},{"id":"a3bb573c.6c1538","type":"switch","z":"b04250e9.7e212","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"cool","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":815,"y":120,"wires":[["8329bb9c.339b18"]],"l":false},{"id":"84ab97e0.6db5f8","type":"switch","z":"b04250e9.7e212","name":"","property":"payload.event.service","propertyType":"msg","rules":[{"t":"eq","v":"set_temperature","vt":"str"},{"t":"eq","v":"set_operation_mode","vt":"str"},{"t":"eq","v":"set_swing_mode","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":575,"y":180,"wires":[["c8e9c5a9.b78508"],["8329bb9c.339b18"],["eb98ab99.2558f8"]],"l":false},{"id":"eb98ab99.2558f8","type":"switch","z":"b04250e9.7e212","name":"","property":"payload.event.service_data.swing_mode","propertyType":"msg","rules":[{"t":"eq","v":"数显","vt":"str"},{"t":"eq","v":"强劲","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":675,"y":240,"wires":[["987cefef.074b2"],["4558d46e.33fabc"]],"l":false},{"id":"987cefef.074b2","type":"api-call-service","z":"b04250e9.7e212","name":"","server":"475c60b.75d4fa","version":1,"service_domain":"switch","service":"turn_on","entityId":"switch.show","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":815,"y":200,"wires":[[]],"l":false},{"id":"4558d46e.33fabc","type":"api-call-service","z":"b04250e9.7e212","name":"","server":"475c60b.75d4fa","version":1,"service_domain":"switch","service":"turn_on","entityId":"switch.strong","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":815,"y":280,"wires":[[]],"l":false},{"id":"89bd84b8.4bca68","type":"server-events","z":"b04250e9.7e212","name":"","server":"475c60b.75d4fa","event_type":"call_service","x":35,"y":180,"wires":[["e4e7618a.50c83"]],"l":false},{"id":"e4e7618a.50c83","type":"switch","z":"b04250e9.7e212","name":"","property":"payload.event.service_data.entity_id","propertyType":"msg","rules":[{"t":"eq","v":"climate.bedgroom","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":160,"y":180,"wires":[["84ab97e0.6db5f8"]],"l":false},{"id":"475c60b.75d4fa","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]
就能在homekit 控制了
简单控制,没有状态反馈,只是利用手头设备实现下功能,能可靠运行确实不太靠谱的。只是满足下折腾的乐趣而已
|
评分
-
参与人数 1 | 金钱 +20 |
收起
理由
|
囧
| + 20 |
能控制已经不错了,10来块钱的玩意~. |
查看全部评分
|