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

 找回密码
 立即注册
楼主: szlww

[经验分享] 【esphome固件】10块钱的空调伴侣计量插座,无损拆机+免...

[复制链接]

10

主题

184

帖子

1822

积分

论坛技术达人

积分
1822
金钱
1633
HASS币
20
 楼主| 发表于 2024-1-17 10:57:32 | 显示全部楼层
自用esphome yaml配置文件。论坛找了一圈,没有完整版本的,自带我家加湿器红外控制的使用示例。这个计量芯片采集的读数来回跳动,比如电压有时候220v,有时候150v,因此电压、电流等传感器均添加中值过滤器去抖动
解压附件的5个yaml配置,到esphome的conf目录下,然后编译,刷机。适配cmcc_x12、电信小翼管家、希智空调伴侣等类似的设备
esphome配置: x12空调伴侣.zip (9.69 KB, 下载次数: 71)

substitutions:
  current_res: "0.001"
  current_multiply: "0.943"
  voltage_div: "1745" # 2351
  hlw8012_sel_pin: GPIO12
  hlw8012_cf_pin: GPIO4
  hlw8012_cf1_pin: GPIO5
  ir_receiver_pin: GPIO13
  ir_transmitter_pin: GPIO14
  button_pin: GPIO0
  led_status_pin: GPIO15

  node_name: "irremote-room1"
  node_name_friendly: ${node_name}
  node_name_add_mac_suffix: "false"

  #可选填
  node_project_name: "cmcc.x12-AcPartner"
  node_project_version: "tywe3s-v1.0.0-webserver2.0"
  node_build_min_version: "2023.12.0"

packages:
  common: !include 1-common-esp8266-1m.yaml
  common-component: !include 1-common-component.yaml
  debug-component: !include 1-debug-component.yaml
  webserver-component: !include 1-webserver-component.yaml

esphome:
  on_boot:
    - priority: 0
      then:
        - lambda: |-
            //配网模式,led快速闪烁;
            if(nullptr != esphome::captive_portal::global_captive_portal)
            {
              //配网模式,蓝色led闪烁
              if(esphome::captive_portal::global_captive_portal->is_active() && !id(id_wifi).is_connected())
              {
                id(id_led_status).turn_off().perform();
                id(id_led_status).turn_on().set_effect("fast").perform();
              }
            }
wifi:
  reboot_timeout: 0s
  on_connect:
    - light.turn_off: id_led_status

logger:
  level: INFO 
  baud_rate: 0

time:
  - platform: homeassistant
    id: id_homeassistant_time
    timezone: "Asia/Shanghai"

output:    
  - platform: esp8266_pwm
    id: id_pin_led_status
    pin: ${led_status_pin}
    inverted: false

light:
  #连接状态指示灯
  - platform: status_led
    name: "API Link Led"
    id: id_led_api_link
    output: id_pin_led_status
    internal: true
  #配网状态指示灯
  - platform: monochromatic
    name: "StatusLed"
    id: id_led_status
    output: id_pin_led_status
    default_transition_length: 0s
    internal: true
    effects:
      - pulse:
          name: "fast"
          transition_length: 0ms
          update_interval: 100ms

sensor:
  - platform: hlw8012
    model: BL0937
    sel_pin: 
      number: ${hlw8012_sel_pin}
      inverted: true
    cf_pin: ${hlw8012_cf_pin}
    cf1_pin: ${hlw8012_cf1_pin}
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    current:
      name: "energy-Current"
      id: id_sensor_current
      filters:
        - multiply: ${current_multiply}
        - median:
            window_size: 5
            send_every: 3
            send_first_at: 3
    voltage:
      name: "energy-Voltage"
      id: id_sensor_voltage
      filters:
        - median:
            window_size: 5
            send_every: 3
            send_first_at: 3
    power:
      name: "energy-Power"
      id: id_sensor_power
    energy:
      name: "energy-Energy"
      id: id_sensor_energy
    update_interval: 3s
    initial_mode: CURRENT
    #change_mode_every: 4294967295

  - platform: copy
    name: energy-MedianPower
    id: id_energy_median_power
    source_id: id_sensor_power
    filters:
      - median:
          window_size: 5
          send_every: 3
          send_first_at: 3

  - platform: total_daily_energy
    name: "energy-DailyEnergy"
    id: id_total_daily_energy_median
    power_id: id_energy_median_power
    accuracy_decimals: 2
    device_class: "energy"
    state_class: "total_increasing"
    icon: "mdi:counter"
    restore: true
    unit_of_measurement: Wh

remote_receiver:
  pin:
    number: ${ir_receiver_pin}
    inverted: true
  #dump: nec
  dump: all
  
remote_transmitter:
  pin: 
    number: ${ir_transmitter_pin}
  carrier_duty_percent: 50%
  
binary_sensor:
  - platform: gpio
    #name: button-Power Key Real
    id: id_power_key
    internal: true
    pin:
      number: ${button_pin}
      inverted: true
      mode:
        input: true
        pullup: true
    on_multi_click:
    #长按5s以上,重置为出厂模式,进入配网状态
    - timing:
        - ON for at least 5s
      then:
        - switch.turn_on: id_factoryreset
      invalid_cooldown: 0s
    - timing:
        - ON for at most 0.5s
        - OFF for at least 0.01s
      then:
        - logger.log: "power button pressed!"
      invalid_cooldown: 0s
    #双击(启动/关闭空调)
    #- timing:
    #    - ON for at most 0.5s
    #    - OFF for at most 0.5s
    #    - ON for at most 0.5s
    #    - OFF for at least 0.2s
    #  then:
    #    - logger.log: "double click."
    #    - 
    #  invalid_cooldown: 0s      
    #单击(启动/关闭加湿器)
    - timing:
        - ON for at most 0.3s
        - OFF for at least 0.2s
      then:
        - logger.log: "single click."
        - button.press: id_button_humidifier_power
      invalid_cooldown: 0s
##加湿器红外键值
##电源 Received NEC: address=0xFF00, command=0xB946 command_repeats=1
##恒湿 Received NEC: address=0xFF00, command=0xF807 command_repeats=1
##档位 Received NEC: address=0xFF00, command=0xF609 command_repeats=1
##定时 Received NEC: address=0xFF00, command=0xF30C command_repeats=1
##睡眠 Received NEC: address=0xFF00, command=0xA15E command_repeats=1
##UV灯 Received NEC: address=0xFF00, command=0xAD52 command_repeats=1
button:
  #加湿器-电源
  - platform: template
    name: Humidifier Power
    id: id_button_humidifier_power
    on_press:
      then:
        - remote_transmitter.transmit_nec:
            address: 0xFF00
            command: 0xB946
  #加湿器-档位
  - platform: template
    name: Humidifier Speed
    id: id_button_humidifier_speed
    on_press:
      then:
        - remote_transmitter.transmit_nec:
            address: 0xFF00
            command: 0xF609
  #加湿器-定时
  - platform: template
    name: Humidifier Timer
    id: id_button_humidifier_timer
    on_press:
      then:
        - remote_transmitter.transmit_nec:
            address: 0xFF00
            command: 0xF30C
  #加湿器-睡眠
  - platform: template
    name: Humidifier Sleep
    id: id_button_humidifier_sleep
    on_press:
      then:
        - remote_transmitter.transmit_nec:
            address: 0xFF00
            command: 0xA15E
#空调组件
#climate:
#  - platform: gree
#    name: "AC"
#    sensor: room_temperature
#    model: yan



回复

使用道具 举报

1

主题

7

帖子

32

积分

新手上路

Rank: 1

积分
32
金钱
25
HASS币
0
发表于 2024-1-24 17:06:11 | 显示全部楼层
楼主威武
回复

使用道具 举报

0

主题

9

帖子

34

积分

新手上路

Rank: 1

积分
34
金钱
25
HASS币
0
发表于 2024-3-14 10:56:25 | 显示全部楼层
谢谢,不容易找到了啊
回复

使用道具 举报

1

主题

88

帖子

914

积分

高级会员

Rank: 4

积分
914
金钱
826
HASS币
0
发表于 2024-3-17 20:42:59 | 显示全部楼层
INFO ESPHome 2023.12.5
INFO Reading configuration /config/esphome/cmcc-x12.yaml...
ERROR Error while reading config: Invalid YAML syntax:

while scanning a simple key
  in "<unicode string>", line 8, column 1
could not find expected ':'
  in "<unicode string>", line 9, column 1
while scanning a simple key
  in "<unicode string>", line 8, column 1
could not find expected ':'
  in "<unicode string>", line 9, column 1
回复

使用道具 举报

1

主题

88

帖子

914

积分

高级会员

Rank: 4

积分
914
金钱
826
HASS币
0
发表于 2024-3-17 20:46:47 | 显示全部楼层
INFO ESPHome 2023.12.5
INFO Reading configuration /config/esphome/cmcc-x12.yaml...
ERROR Error while reading config: Invalid YAML syntax:

while scanning a simple key
  in "<unicode string>", line 8, column 1
could not find expected ':'
  in "<unicode string>", line 9, column 1
while scanning a simple key
  in "<unicode string>", line 8, column 1
could not find expected ':'
  in "<unicode string>", line 9, column 1
请问楼主,这个是啥原因呢
回复

使用道具 举报

0

主题

73

帖子

292

积分

中级会员

Rank: 3Rank: 3

积分
292
金钱
219
HASS币
0
发表于 2024-3-18 16:06:00 | 显示全部楼层

谢谢分享!刚买了两个小翼的空调伴侣,回头试一下。
回复

使用道具 举报

0

主题

10

帖子

64

积分

注册会员

Rank: 2

积分
64
金钱
54
HASS币
0
发表于 2024-4-3 17:23:19 | 显示全部楼层
刷机固件哪里有
回复

使用道具 举报

0

主题

10

帖子

64

积分

注册会员

Rank: 2

积分
64
金钱
54
HASS币
0
发表于 2024-4-6 16:10:37 | 显示全部楼层
烧录怎么接线?10O和rst需要短接吗?
回复

使用道具 举报

0

主题

10

帖子

64

积分

注册会员

Rank: 2

积分
64
金钱
54
HASS币
0
发表于 2024-4-7 13:03:57 | 显示全部楼层
编译时候报错
回复

使用道具 举报

0

主题

10

帖子

64

积分

注册会员

Rank: 2

积分
64
金钱
54
HASS币
0
发表于 2024-4-8 11:07:32 | 显示全部楼层
ccz888888 发表于 2024-3-18 16:06
谢谢分享!刚买了两个小翼的空调伴侣,回头试一下。

兄弟你搞定了吗?我编译的时候报错
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-25 00:45 , Processed in 0.074310 second(s), 32 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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