本帖最后由 shadowba 于 2023-7-12 16:39 编辑
老上菱单冷空调,96年生产,虽然很久,本着勤俭持家的原则还是不换了。遥控器死难用,北鼻无奈买了一个米家空调伴侣2,搞笑的是居然无法匹配??!!唉。。。。。
自己做一个控制板吧,拆除原室内机内脏
在地上随便捡一个旧的风盘控制器改造一下,风盘控制器有零线/火线/风机高挡/风机中挡/风机低挡和阀控接线端子,刚好为我所用。阀控继电器功率较小,经检查发现空调室外机继电器刚好也是12v控制,所以就从风盘阀控继电器弱电端直接驱动原空调室内机内的室外机继电器。
diy需要灵活运用,灵活发挥。
加入室内温度检测和室内机换热器温度检测
装机测试
已通过巴法云接入小爱同学,效果还不错,现已正常服役,可显示送风模式档位、制冷设定的稳定、关闭状态、关闭5秒后显示时钟。
红外控制待完善。代码如下:
esphome:
name: "shangling"
friendly_name: "shangling"
platformio_options:
board_build.flash_mode: dio
board_build.mcu: esp32c3
esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf
version: recommended
# Custom sdkconfig options
sdkconfig_options:
CONFIG_COMPILER_OPTIMIZATION_SIZE: y
# Advanced tweaking options
advanced:
ignore_efuse_mac_crc: false
logger:
hardware_uart: USB_SERIAL_JTAG
#logger:
# Enable logging
# Enable Home Assistant API
api:
ota:
password: "xxxxxxxxxx"
wifi:
networks:
- ssid: xxxxxx
password: xxxxxxxxxx
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "climate Fallback Hotspot"
password: "trRclijXb3T4"
time:
- platform: homeassistant
id: homeassistant_time
sensor:
#盘管温度检测
- platform: dallas
dallas_id: hub_1
address: 0x013ce1e07601d428
id: pgtemperature
name: "pgtemp"
#室内温度检测
- platform: dallas
dallas_id: hub_2
address: 0xfb3cdcf649306728
name: "sntemp"
id: sntemperature
dallas:
- pin: GPIO4
id: hub_1
update_interval: 10s
- pin: GPIO5
id: hub_2
update_interval: 10s
display:
platform: tm1637
id: tm1637_display
clk_pin: 0
dio_pin: 1
# inverted: true
length: 4
update_interval: 500ms
lambda: |-
static int i = 0;
i++;
if (id(relay_1).state == true && id(valve).state == false ) {
it.print("FS-1");
} else if (id(relay_2).state == true && id(valve).state == false) {
it.print("FS-2");
} else if (id(relay_3).state == true && id(valve).state == false) {
it.print("FS-3");
} else if (id(ventilate).state == true && id(valve).state == true) {
it.printf(0, "-%.0f-", id(mythermostat).target_temperature );
} else if (id(relay_4).state == true && id(ventilate).state == false && id(valve).state == false) {
it.print(1,"OFF");
} else if (id(relay_4).state == false && (i % 2) == 0 && id(valve).state == false)
it.strftime("%H.%M", id(homeassistant_time).now());
else
it.strftime("%H%M", id(homeassistant_time).now());
#remote_receiver:
# pin:
# number: 7
# inverted: true
# mode:
# input: true
# pullup: true
# dump: all
switch:
# relay 1 风扇 low
- platform: gpio
pin: 10
# name: "Fan low"
id: relay_1
interlock: &interlock_group [relay_1, relay_2, relay_3]
interlock_wait_time: 50ms
restore_mode: ALWAYS_OFF
# relay 2 风扇 mid
- platform: gpio
pin: 3
# name: "Fan mid"
id: relay_2
interlock: *interlock_group
interlock_wait_time: 50ms
restore_mode: ALWAYS_OFF
# relay 3 风扇 high
- platform: gpio
pin: 2
# name: "Fan high"
id: relay_3
interlock: *interlock_group
interlock_wait_time: 50ms
restore_mode: ALWAYS_OFF
# 时间切换
- platform: gpio
pin: 8
id: relay_4
restore_mode: ALWAYS_OFF
# relay 4 室外机继电器
- platform: gpio
pin: 6
name: "valve"
id: valve
icon: "mdi:valve"
restore_mode: ALWAYS_OFF
# internal: true
# on_turn_on:
# - switch.turn_on: relay_6
# on_turn_off:
# - switch.turn_off: relay_6
#制冷指示灯
- platform: gpio
pin: 1
id: relay_6
# name: "refrigeration"
inverted: false
restore_mode: ALWAYS_OFF
# 电源指示灯
- platform: gpio
pin: 0
id: relay_7
# name: "power"
inverted: false
restore_mode: ALWAYS_OFF
# setting up fan with output to corresponding fanspeed
#风扇组件
fan:
- platform: speed
id: ventilate
output: custom_fan
name: "Climate Fan"
speed_count: 3
output:
- platform: template
id: custom_fan
type: float
write_action:
- if:
condition:
lambda: return ((state ==0));
then:
#action for off
- switch.turn_off: relay_1
- switch.turn_off: relay_2
- switch.turn_off: relay_3
- if:
condition:
lambda: return (( state > .16) && (state < .34));
then:
# action for low
- switch.turn_on: relay_1
- if:
condition:
lambda: return ((state > .35) && (state < .7));
then:
# action for medium
- switch.turn_on: relay_2
- if:
condition:
lambda: return ((state ==1));
then:
# action for high
- switch.turn_on: relay_3
# setting up climate conrol
climate:
- platform: thermostat
id: mythermostat
name: "Climate Controller"
sensor: sntemperature
visual:
min_temperature: 17
max_temperature: 30
temperature_step: 0.1°C
min_cooling_off_time: 5s
min_cooling_run_time: 5s
min_fan_mode_switching_time: 1s
min_fanning_off_time: 5s
min_fanning_run_time: 5s
min_idle_time: 5s
# fan_with_cooling: true
#制冷模式
cool_action:
- fan.turn_on: ventilate
- switch.turn_on: valve
#空闲模式
idle_action:
- switch.turn_off: valve
- switch.turn_off: relay_6
dry_action:
- fan.turn_on: ventilate
- switch.turn_on: valve
default_preset: home
on_boot_restore_from: memory
preset:
- name: home
default_target_temperature_high: 26
fan_mode: medium
mode: cool
cool_mode:
# - switch.turn_on: valve
# - fan.turn_on: ventilate
- switch.turn_on: relay_6
- switch.turn_on: relay_7
dry_mode:
- switch.turn_on: relay_6
- switch.turn_on: relay_7
off_mode:
- switch.turn_off: valve
- fan.turn_off: ventilate
- switch.turn_off: relay_6
- switch.turn_off: relay_7
fan_only_action:
- switch.turn_off: valve
- fan.turn_on: ventilate
- switch.turn_off: relay_6
- switch.turn_on: relay_7
fan_mode_low_action:
lambda: !lambda |-
auto call = id(ventilate).turn_on();
call.set_speed(1);
call.perform();
fan_mode_medium_action:
lambda: !lambda |-
auto call = id(ventilate).turn_on();
call.set_speed(2);
call.perform();
fan_mode_high_action:
lambda: !lambda |-
auto call = id(ventilate).turn_on();
call.set_speed(3);
call.perform();
fan_mode_off_action:
- fan.turn_off: ventilate
fan_mode_on_action:
- fan.turn_on: ventilate
|