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

 找回密码
 立即注册
查看: 64439|回复: 105

[进阶教程] 魅族红外遥控空调,+Homekit控制,个人笔记

  [复制链接]

4

主题

250

帖子

1293

积分

金牌会员

Rank: 6Rank: 6

积分
1293
金钱
1043
HASS币
0
发表于 2019-8-26 11:27:24 | 显示全部楼层 |阅读模式
本帖最后由 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来块钱的玩意~.

查看全部评分

回复

使用道具 举报

27

主题

2143

帖子

8930

积分

论坛元老

Rank: 8Rank: 8

积分
8930
金钱
6782
HASS币
30

论坛元老

发表于 2019-8-26 11:34:19 | 显示全部楼层
好帖,顶一下,适合小白党
回复

使用道具 举报

1

主题

108

帖子

769

积分

高级会员

Rank: 4

积分
769
金钱
661
HASS币
0
发表于 2019-8-26 12:17:45 | 显示全部楼层
这车要变飞机,起飞了
回复

使用道具 举报

8

主题

2073

帖子

6053

积分

论坛元老

流水无味

Rank: 8Rank: 8

积分
6053
金钱
3980
HASS币
145

灌水之王

发表于 2019-8-26 12:49:30 | 显示全部楼层
一直在用温湿度, 改天试试遥控
回复

使用道具 举报

8

主题

736

帖子

4568

积分

论坛元老

Rank: 8Rank: 8

积分
4568
金钱
3827
HASS币
40
QQ
发表于 2019-8-26 13:35:13 | 显示全部楼层
感谢分享
回复

使用道具 举报

24

主题

884

帖子

5055

积分

论坛元老

Rank: 8Rank: 8

积分
5055
金钱
4166
HASS币
20
发表于 2019-8-26 14:44:00 来自手机 | 显示全部楼层
这东西有蓝牙遥控的功能
回复

使用道具 举报

4

主题

250

帖子

1293

积分

金牌会员

Rank: 6Rank: 6

积分
1293
金钱
1043
HASS币
0
 楼主| 发表于 2019-8-26 15:30:16 | 显示全部楼层
chenquanhao 发表于 2019-8-26 14:44
这东西有蓝牙遥控的功能

只是红外遥控,魅族遥控器是需要蓝牙连接,所以需要esp32当蓝牙网关而已。群里10元车,温湿度 红外遥控划算
回复

使用道具 举报

40

主题

1129

帖子

4256

积分

论坛元老

Rank: 8Rank: 8

积分
4256
金钱
3127
HASS币
0
发表于 2019-8-26 16:01:09 | 显示全部楼层
xieahui 发表于 2019-8-26 12:49
一直在用温湿度, 改天试试遥控

hk里面检测到电池容量只剩3%了
回复

使用道具 举报

10

主题

680

帖子

5650

积分

论坛元老

Rank: 8Rank: 8

积分
5650
金钱
4965
HASS币
50
发表于 2019-8-26 16:25:45 | 显示全部楼层
可以,不错!
回复

使用道具 举报

0

主题

48

帖子

324

积分

中级会员

Rank: 3Rank: 3

积分
324
金钱
276
HASS币
0
发表于 2019-8-26 17:39:43 | 显示全部楼层
学习学习
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-24 22:51 , Processed in 0.071539 second(s), 34 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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