某动X12空调伴侣esphome固件分享 2023.6.24 更新功率部分
本帖最后由 ylilike 于 2024-4-10 16:42 编辑时隔久远,看有回帖编译失败的,于是编译了一个
放上来,需要自取
天热想起空调了,更新一波吧(yaml附件,请移步46楼)
某动X12空调伴侣,刷入esphome固件,再配置 ryanh7大佬 插件,可完美接入ha
Smartac+esphome 理论上兼容200多种品牌老空调
插件地址:
https://bbs.hassbian.com/thread-15867-1-1.html
使用方法:
https://bbs.hassbian.com/thread-15827-1-1.html
可惜我家的whirlpool还是不能用,自己不能用,就分享给朋友们吧。
核心代码如下了,太长贴不全,还有之前分享的在二楼,组合起来,应该可以完美使用了。
'''
substitutions:
plug_name: x12_remote_1
# Higher value gives lower watt readout
current_res: "0.005"
# Lower value gives lower voltage readout
voltage_div: "369" # 369
esphome:
name: ${plug_name}
platform: ESP8266
board: esp_wroom_02
on_boot:
priority: 600
then:
- lambda: |-
id(Voltage).publish_state(id(y_voltage).state + 116.3);
id(Amperage).publish_state(id(Wattage).state / (id(y_voltage).state + 116.3) );
id(ctrl_text).publish_state("若然,一切若然~");
wifi:
ssid: !secret wifi_2 # wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.3.207
gateway: 192.168.3.254
subnet: 255.255.255.0
dns1: 192.168.3.254
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "x12_remote_1_Hotspot"
password: !secret fallwifi_pswd
captive_portal:
# Enable logging
logger:
level: debug #makes uart stream available in esphome logstream
# baud_rate: 0 #disable logging over uart
# Enable Home Assistant API
api:
password: !secret api_password
services:
- service: send_raw_command
variables:
command: int[]
then:
- remote_transmitter.transmit_raw:
code: !lambda 'return command;'
carrier_frequency: 38k
- service: ctrl_text
variables:
target: string
then:
- lambda: |-
id(ctrl_text).publish_state(target);
ota:
password: !secret ota_password
web_server:
port: 80
time:
- platform: sntp
id: my_time
sensor:
- platform: hlw8012
sel_pin:
number: 12
inverted: True
cf_pin: 4
cf1_pin: 5
#current_resistor: ${current_res}
voltage_divider: ${voltage_div}
# current:
# name: "${plug_name}_Amperage"
# unit_of_measurement: A
voltage:
id: y_voltage
name: z_voltage
unit_of_measurement: V
power:
name: "${plug_name}_Wattage"
unit_of_measurement: W
id: Wattage
update_interval: 10s
initial_mode: VOLTAGE # VOLTAGE 或 CURRENT
change_mode_every: 8#默认8 # 4294967295
- platform: template
name: "${plug_name}_Voltage"
id: Voltage
icon: "mdi:sine-wave"
- platform: template
name: "${plug_name}_Amperage"
id: Amperage
icon: "mdi:current-ac"
- platform: total_daily_energy
name: "${plug_name}_Total_Daily_Energy"
power_id: "Wattage"
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
# Extra sensor to keep track of plug uptime
- platform: uptime
name: ${plug_name}_Uptime
# Extra sensor to keep track of plug uptime
- platform: uptime
name: ${plug_name}_Uptime
binary_sensor:
- platform: template
name: "${plug_name}_Power"
id: Power
device_class: power
interval:
- interval: 3s #定时
then:
- lambda: |-
id(Voltage).publish_state(id(y_voltage).state + 116.3);
id(Amperage).publish_state(id(Wattage).state / (id(y_voltage).state + 116.3) );
if( id(Wattage).state > 3){
id(Power).publish_state(true);
if(id(led_switch).state){
id(led).turn_on();
}
}else{
id(Power).publish_state(false);
id(led).turn_off();
}
remote_receiver:
pin:
number: 13 #接收
inverted: True
#dump: nec
dump: all
remote_transmitter:
pin:
number: 14 #发射
carrier_duty_percent: 50%
'''
esphome:
name: x12-test
esp8266:
board: esp01_1m
# Enable Home Assistant API
api:
password: "yiqieruoran"
services:
- service: send_raw_command
variables:
command: int[]
then:
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
code: !lambda 'return command;'
ota:
password: "yiqieruoran" # 一切若然
wifi:
# ssid: "ssid"
# password: "yiqieruoran" # 一切若然
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "X12-Test_Hotspot"
captive_portal:
# Enable logging
logger:
# level: VERBOSE #makes uart stream available in esphome logstream
# baud_rate: 0 #disable logging over uart
# Enable Home Assistant API
# web_server:
# port: 80
remote_receiver:
pin:
number: 13 #接收
inverted: True
#dump: nec
dump: all
remote_transmitter:
pin:
number: 14 #发射
carrier_duty_percent: 50%
switch:
- platform: gpio
name: x12_led
id: x12_led
pin: 15
inverted: false 谢谢分享,占位 支持一下,感谢分享 :lol:lol:lol:lol:lol:lol X12有个功率计 支持一下,感谢分享 刷这个固件 功率计是不是就没有用了额啊?
膜拜大神,补了半天得课,也没有想明白到底应该怎么弄,现在连python环境还没有搭建好,我是不是可以放弃了、、、、、
confessor 发表于 2023-6-23 15:46
刷这个固件 功率计是不是就没有用了额啊?
把功率部分也补上了,一楼已更新了