esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

Midea Eco preset does not work, autoconfig enabled #3880

Open DjordjeMandic opened 1 year ago

DjordjeMandic commented 1 year ago

The problem

Selecting Eco in climate presets does nothing. AC does not beep like it does on any command. After 1-2seconds preset in homeassistant changes to what it was before selecting Eco. If it was on None after selecting Eco it stays in Eco preset for 1-2seconds and returns to None, ac does not beep. Same if it was Boost or Freeze Protection or Sleep. Autoconfig added it because ac reported it.

Which version of ESPHome has the issue?

2022.11.5

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2022.11.5

What platform are you using?

ESP32

Board

custom esp32c3 board

Component causing the issue

midea

Example YAML snippet

climate:
  - platform: midea
    name: Samsung AR3500        # Use a unique name.
    period: 1s                  # Optional
    timeout: 2s                 # Optional
    num_attempts: 3             # Optional
    autoconf: true              # Autoconfigure most options.
    beeper: true                # Beep on commands.
    supported_presets:          # All capabilities in this section detected by autoconf.
      - BOOST
      - SLEEP  
    outdoor_temperature:        # Optional. Outdoor temperature sensor (may display incorrect values after long inactivity).
      name: AirCon Outdoor Air Temperature

Anything in the logs that might be useful for us?

Preset None, 25c set, fan auto, swing off, operation heat:

[18:33:36][C][midea:103]: MideaDongle:
[18:33:36][C][midea:104]:   [x] Period: 1000ms
[18:33:36][C][midea:105]:   [x] Response timeout: 2000ms
[18:33:36][C][midea:106]:   [x] Request attempts: 3
[18:33:36][C][midea:108]:   [x] Using RemoteTransmitter
[18:33:36][C][Capabilities:279]: CAPABILITIES REPORT:
[18:33:36][C][Capabilities:281]:   [x] AUTO MODE
[18:33:36][C][Capabilities:282]:       - MIN TEMP: 17.0
[18:33:36][C][Capabilities:283]:       - MAX TEMP: 30.0
[18:33:36][C][Capabilities:286]:   [x] COOL MODE
[18:33:36][C][Capabilities:287]:       - MIN TEMP: 17.0
[18:33:36][C][Capabilities:288]:       - MAX TEMP: 30.0
[18:33:36][C][Capabilities:291]:   [x] HEAT MODE
[18:33:36][C][Capabilities:292]:       - MIN TEMP: 17.0
[18:33:36][C][Capabilities:293]:       - MAX TEMP: 30.0
[18:33:36][C][Capabilities:295]:   [x] DRY MODE
[18:33:36][C][Capabilities:296]:   [x] ECO MODE
[18:33:36][C][Capabilities:298]:   [x] FROST PROTECTION MODE
[18:33:36][C][Capabilities:299]:   [x] TURBO COOL
[18:33:36][C][Capabilities:300]:   [x] TURBO HEAT
[18:33:36][C][Capabilities:301]:   [x] FANSPEED CONTROL
[18:33:36][C][Capabilities:304]:   [x] UPDOWN FAN
[18:33:36][C][Capabilities:305]:   [x] LEFTRIGHT FAN
[18:33:36][C][midea:538]: ClimateTraits:
[18:33:36][C][midea:539]:   [x] Visual settings:
[18:33:36][C][midea:540]:       - Min: 17.0
[18:33:36][C][midea:541]:       - Max: 30.0
[18:33:36][C][midea:542]:       - Step: 0.5
[18:33:36][C][midea:544]:   [x] Supports current temperature
[18:33:36][C][midea:550]:   [x] Supported modes:
[18:33:36][C][midea:552]:       - OFF
[18:33:36][C][midea:552]:       - HEAT_COOL
[18:33:36][C][midea:552]:       - COOL
[18:33:36][C][midea:552]:       - HEAT
[18:33:36][C][midea:552]:       - FAN_ONLY
[18:33:36][C][midea:552]:       - DRY
[18:33:36][C][midea:555]:   [x] Supported fan modes:
[18:33:36][C][midea:557]:       - AUTO
[18:33:36][C][midea:557]:       - LOW
[18:33:36][C][midea:557]:       - MEDIUM
[18:33:36][C][midea:557]:       - HIGH
[18:33:36][C][midea:565]:   [x] Supported presets:
[18:33:36][C][midea:567]:       - NONE
[18:33:36][C][midea:567]:       - BOOST
[18:33:36][C][midea:567]:       - ECO
[18:33:36][C][midea:567]:       - SLEEP
[18:33:36][C][midea:570]:   [x] Supported custom presets:
[18:33:36][C][midea:572]:       - freeze protection
[18:33:36][C][midea:575]:   [x] Supported swing modes:
[18:33:36][C][midea:577]:       - OFF
[18:33:36][C][midea:577]:       - VERTICAL

[17:57:48][D][AirConditioner:178]: Enqueuing a GET_STATUS(0x41) request...
[17:57:48][D][ApplianceBase:173]: Enqueuing the request...
[17:57:48][D][ApplianceBase:075]: Getting and sending a request from the queue...
[17:57:48][D][ApplianceBase:162]: TX: AA 21 AC 8D 00 00 00 00 03 03 41 81 00 FF 03 FF 00 02 00 00 00 00 00 00 00 00 00 00 00 00 03 89 27 28 
[17:57:48][D][ApplianceBase:063]: RX: AA 22 AC 00 00 00 00 00 03 03 C0 01 89 66 7F 7F 00 30 00 00 00 6D 3C 00 00 00 00 00 00 00 00 00 27 1F 5F 
[17:57:48][D][AirConditioner:205]: New status data received. Parsing...
[17:57:48][D][ApplianceBase:154]: Destroying the request...

Additional information

AC: SAMSUNG AR12TXHQASINEU - AR3500

devmarxx commented 1 year ago

Same problem with the same hardware here.

Regards

Chris

gedas07 commented 1 year ago

Hello I have the same AC samsung AR12TXHQASINEU , but for me it is impossible for the esphome midea component to work Could you send me how you did it to make it work for you, and with which board? And if possible, any photos of how it looks thank you very much

DjordjeMandic commented 1 year ago

@gedas07

I made this quick prototype and its running for a year almost.

As of yaml, i can't access it currently. I followed basic configuration tutorial and it worked.

Only issue I'm currently having is that it's not recognized on first power on after power loss. There is no wifi symbol on ac. (also web server on esphome does not work). Manually power cycling the ac does the trick. I still gotta debug that.

I can try to find yaml and schematic of the board somewhere (due to some of my laziness my home assistant(including esphome) is offline for past 7 months)

How did you wire it up? Did you use level shifters? Serial on AC is at 5V. I accessed it on CN3. Also i hard wired IR receiver signal because it's not broken out at CN3. Look at the photos on Instagram for CN3

devmarxx commented 1 year ago

I use the ESP-01 and took the UART module to get access. This video shows the hardware and how to get access through the UART module.

https://youtu.be/6uaIWZCRSz8

These are the pictures of how I connected the ESP-01 to the unit:

IMG_20221213_182309

IMG_20221213_182251

Sorry for the bad quality, but you "get the picture" :-)

Regards

Chris

devmarxx commented 1 year ago

I do have the wifi symbol, but I did not connect IR, No issues on first power.

Regards

Chris

gedas07 commented 1 year ago

@devmarxx @DjordjeMandic Thank you very much to both of you It seems easier to me the way @devmarxx devmarx has done it, @devmarxx Could you send me the code of the yaml that you put in it please? Didn't you need to put a voltage exchanger for the RX and TX?

And it works perfectly with Home Assistant? Could you put me a little video of how it works if possible I'm going to buy the components to make it Thanks a lot

devmarxx commented 1 year ago

I'm not using Homeassistant. I'm using the build in webserver, because I manage the unit with my own python control scripts over wifi with a Raspberry Pi. But without the webserver Homeassistant should work.

ac

Here my yaml:

online-yaml.txt

This is a specific configuration to communicate with my python scripts (they are too unique to my situation, I'm not going to share them), but it should work for you as a starting point.

Regards

Chris

devmarxx commented 1 year ago

O ... No voltage exchanger needed.

Regards

Chris

gedas07 commented 1 year ago

Thanks a lot , waiting for the components to arrive to be able to assemble it

devmarxx commented 1 year ago

You're welcome.

Let us know how it worked out for you, if you like.

gedas07 commented 1 year ago

And with what program did you flash the esp-01? with this? https://web.esphome.io/?dashboard_install

gedas07 commented 1 year ago

@devmarxx And on the plate where is the temperature turns on the wifi symbol? All the time? or only when starting the AC?

DjordjeMandic commented 1 year ago

@gedas07 Wifi symbol is on only when the display on the cover is on. If ac is off or display is off then wifi symbol is also off

gedas07 commented 1 year ago

@DjordjeMandic ok , my wifi simbol is off all the time , but for the moment only i try with wemos d1 mini , but don't work. i don't have response from RX

I'll waiting the new components

devmarxx commented 1 year ago

The wifi symbol behaves exactly as described by @DjordjeMandic

gedas07 commented 1 year ago

@devmarxx @DjordjeMandic Ok thanks again, that is, when connecting the ESP-01 to the AC, the Wi-Fi icon will be on whenever the AC is on, correct? Does something do in the AC apart from connecting the programmed ESP-01? How to touch a key in the command to activate the wifi or something?

devmarxx commented 1 year ago

I use "esptool" (python) to compile and (first) flash. After the first flash I update with the webfrontend.

DjordjeMandic commented 1 year ago

As soon as mideauart library(esphome in this case) starts communication on the serial lines ac will recognize it and turn on wifi symbol. Basically as soon as esp queries data from AC it will turn on wifi symbol. You don't have to do anything in order for wifi symbol to show up. If you just connect everything and power on if it's working it will turn on wifi symbol.

gedas07 commented 1 year ago

thanks

DjordjeMandic commented 1 year ago

@gedas07

Idk if this is fixed but it might be of some help for understanding yaml below.

Board used: Instagram

Schematic:

Schematic_IoT AC WiFi Adapter_2023-08-22

YAML

external_components:
  - source: github://Jorre05/remote_receiver
    components: [ remote_receiver ] # Modded component with option to specify RMT channel. (ESP32-C3 0/1 TX - 2/3 RX)

esphome:
  name: samsungac
  comment: Living room ESP32-C3 Samsung AC WiFi adapter
  includes:
    - ESP32InternalTemperature.h
  project:
    name: "djordje_mandic.iot_ac_wifi_adapter"
    version: "1.0.0"
  on_boot:
    - number.set:
        id: log_warning_cnt
        value: 0
    - number.set:
        id: log_error_cnt
        value: 0

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino
    version: 2.0.3
    platform_version: 4.4.0

globals:
  - id: wifiredstate
    type: bool
    restore_value: no
    initial_value: 'false'
  - id: apiredstate
    type: bool
    restore_value: no
    initial_value: 'false'

number:
  - platform: template
    id: log_warning_cnt
    internal: true
    entity_category: "diagnostic"
    optimistic: true
    min_value: 0
    max_value: 9999999
    step: 1
    on_value:
      then:
        - sensor.template.publish:
            id: warn_cnt_sensor
            state: !lambda "return x;"
  - platform: template
    id: log_error_cnt
    internal: true
    entity_category: "diagnostic"
    optimistic: true
    min_value: 0
    max_value: 9999999
    step: 1
    on_value:
      then:
        - sensor.template.publish:
            id: err_cnt_sensor
            state: !lambda "return x;"

# Enable logging and flash internal led on warning/error 
logger:
  baud_rate: 0
  on_message: 
    - level: WARN
      then:
        - number.increment:
            id: log_warning_cnt
            cycle: false
        - if:
            condition:
              and:
                - api.connected:
                - wifi.connected: 
            then:
              - light.turn_on:
                  id: internal_led
                  brightness: 45%
                  red: 100%
                  green: 100%
                  blue: 0%
              - delay: 500ms
              - light.turn_off: internal_led
    - level: ERROR
      then:
        - number.increment:
            id: log_error_cnt
            cycle: false
        - if:
            condition:
              and:
                - api.connected:
                - wifi.connected: 
            then:
              - light.turn_on:
                  id: internal_led
                  brightness: 45%
                  red: 100%
                  green: 0%
                  blue: 0%
              - delay: 500ms
              - light.turn_off: internal_led

syslog:
  ip_address: x
  port: 514
  min_level: INFO

debug:
  update_interval: 5s

script:
  - id: flash_info_led_follow_room_temp
    mode: single
    then:
      - light.turn_on:
          id: internal_led
          brightness: 55%
          red: 0%
          green: 0%
          blue: 100%
      - delay: 500ms
      - light.turn_off: internal_led

interval:
  # flash status led in blue color if follow me is on
  - interval: 10s
    then:
      - if:
          condition:
            and:
              - switch.is_on: follow_room_temp_sw
              - light.is_off: internal_led
          then:
              - script.execute: flash_info_led_follow_room_temp

  # check for wifi and api connection and update status led
  - interval: 1s
    then:
      - lambda: |-
          if(!wifi_wificomponent->is_connected())
          {
            auto call = id(internal_led).turn_on();
            call.set_brightness(0.5);
            call.set_rgb(1.0, 0.0, 0.0);
            call.perform();
            id(wifiredstate) = true;
          }
          else
          {
            if(id(wifiredstate))
            {
              auto call = id(internal_led).turn_off();
              call.perform();
              id(wifiredstate) = false;
            }
            if(!global_api_server->is_connected())
            {
              auto call = id(internal_led).turn_on();
              call.set_brightness(0.5);
              call.set_rgb(1.0, 0.0, 1.0);
              call.perform();
              id(apiredstate) = true;
            }
            else
            {
              if(id(apiredstate))
              {
                auto call = id(internal_led).turn_off();
                call.perform();
                id(apiredstate) = false;
              }
            }
          }

uart:
  tx_pin: GPIO21         
  rx_pin: GPIO20         
  baud_rate: 9600

dallas:
  pin: GPIO4
  update_interval: 1s

text_sensor:
  - platform: debug
    device:
      name: "Device Info"
      entity_category: "diagnostic"
    reset_reason:
      name: "Reset Reason"
      entity_category: "diagnostic"
  #
  - platform: template
    name: AirCon WiFi Adapter Uptime
    id: uptime_human
    icon: mdi:clock-start
  #
  - platform: version
    name: "ESPHome Version"
    entity_category: "diagnostic"
  #
  - platform: wifi_info
    ip_address:
      name: ESP IP Address
      entity_category: "diagnostic"
    ssid:
      name: ESP Connected SSID
      entity_category: "diagnostic"
    bssid:
      name: ESP Connected BSSID
      entity_category: "diagnostic"
    mac_address:
      name: ESP Mac Wifi Address
      entity_category: "diagnostic"
    scan_results:
      name: ESP Latest Scan Results
      entity_category: "diagnostic"

# Remote transmitter, should be on RMT channel 0
remote_transmitter:
  pin: GPIO18
  carrier_duty_percent: 100% # directly connected to ir receiver data

light:
  # internal addressable rgb led, TX via RMT Channel: 1
  - platform: neopixelbus
    id: internal_led
    type: GRB
    variant: 800KBPS
    pin: GPIO7
    method:
      type: esp32_rmt
      channel: 1
    num_leds: 1
    default_transition_length: 0s
    entity_category: "diagnostic"
    name: "AirCon WiFi Adapter Internal LED"

# Remote receiver, should be RMT Channel 2
remote_receiver:
  pin:
    number: GPIO19
    inverted: true
  rmt_channel: 2

climate:
  - platform: midea
    id: midea_climate
    name: Living room AC        # Use a unique name.
    period: 1s                  # Optional
    timeout: 2s                 # Optional
    num_attempts: 3             # Optional
    autoconf: false              # Autoconfigure most options.
    beeper: true                # Beep on commands.
    visual:                     # Optional. Example of visual settings override.
      min_temperature: 17 °C    # min: 17
      max_temperature: 30 °C    # max: 30
      temperature_step: 1 °C    # min: 1
    supported_modes:            # All capabilities in this section detected by autoconf.
      - FAN_ONLY                # This capability is always used.
      - HEAT_COOL
      - COOL
      - HEAT
      - DRY
    supported_presets:          # All capabilities in this section detected by autoconf.
      - BOOST
      - SLEEP  
    custom_presets:             # All capabilities in this section detected by autoconf.
      - FREEZE_PROTECTION
    supported_swing_modes:
      - VERTICAL                # This capability is always used.
    outdoor_temperature:        # Optional. Outdoor temperature sensor (may display incorrect values after long inactivity).
      name: AirCon Outdoor Air Temperature

sensor:
  - platform: debug
    free:
      name: "Heap Free"
    block:
      name: "Heap Max Block"
    loop_time:
      name: "Loop Time"
  #
  - platform: custom
    lambda: |-
      auto internal_temp = new ESP32InternalTemperature();
      App.register_component(internal_temp);
      return {internal_temp};
    sensors:
      name: "ESP32-C3 Temperature"
      entity_category: "diagnostic"
      unit_of_measurement: "°C"
  #
  - platform: dallas
    address: 0x44041703f940ff28
    name: "AirCon Indoor Pipe #1 Temperature"
    id: pipe1_temp
    on_value_range:
      - below: 0.0
        then:
          lambda: |-
            if(id(midea_climate).mode == CLIMATE_MODE_DRY || id(midea_climate).mode == CLIMATE_MODE_COOL)
            {
              auto call = id(midea_climate).make_call();
              call.set_mode(CLIMATE_MODE_FAN_ONLY);
              call.perform();
              ESP_LOGE("protection", "Failsafe protection triggered. Evaporator coil started freezing in COOL/DRY mode. Switched to FAN_ONLY.");
            }
#    entity_category: "diagnostic"
  #
  - platform: dallas
    address: 0x910517032c69ff28
    name: "AirCon Indoor Pipe #2 Temperature"
    id: pipe2_temp
    on_value_range:
      - below: 0.0
        then:
          lambda: |-
            if(id(midea_climate).mode == CLIMATE_MODE_DRY || id(midea_climate).mode == CLIMATE_MODE_COOL)
            {
              auto call = id(midea_climate).make_call();
              call.set_mode(CLIMATE_MODE_FAN_ONLY);
              call.perform();
              ESP_LOGE("protection", "Evaporator coil started freezing in COOL/DRY mode. Switched to FAN_ONLY.");
            }

#    entity_category: "diagnostic"
  - platform: template
    name: "AirCon Indoor Unit Temperature Difference"
    lambda: |-
      return id(pipe1_temp).state - id(pipe2_temp).state;
    update_interval: 1s
    unit_of_measurement: "°C"
  #
  - platform: dallas
    address: 0x2e041703d0d8ff28
    name: "AirCon Outlet Air Temperature"
  #
  - platform: dht
    pin: GPIO5
    temperature:
      id: dht_temp
      name: "Living Room Temperature"
    humidity:
      id: dht_humi
      name: "Living Room Humidity"
    update_interval: 3s
  - platform: copy
    source_id: dht_temp
    id: dht_temp_follow_me
    internal: true
    filters:
      - throttle: 10s
      - heartbeat: 15s             # Maximum interval between updates.
      - debounce: 1s
    on_value:
      if:
        condition:
          switch.is_on: follow_room_temp_sw
        then:
          - midea_ac.follow_me:
              temperature: !lambda "return x;"
              beeper: false               # Optional. Beep on update.
          - logger.log: 
              level: INFO
              format: "Follow me temperature updated to %i, actual %.1f"
              args: ['lroundf(id(dht_temp_follow_me).state)', 'id(dht_temp_follow_me).state']
              tag: "MideaFollowMe"
  #
  - platform: uptime
    name: AirCon WiFi Adapter Uptime
    id: uptime_sensor
    update_interval: 1s
    on_raw_value:
      then:
        - text_sensor.template.publish:
            id: uptime_human
            state: !lambda |-
              int seconds = round(id(uptime_sensor).raw_state);
              int days = seconds / (24 * 3600);
              seconds = seconds % (24 * 3600);
              int hours = seconds / 3600;
              seconds = seconds % 3600;
              int minutes = seconds /  60;
              seconds = seconds % 60;
              return (
                (days ? to_string(days) + "d " : "") +
                (hours ? to_string(hours) + "h " : "") +
                (minutes ? to_string(minutes) + "m " : "") +
                (to_string(seconds) + "s")
              ).c_str();
  #
  - platform: template
    name: "Log Warning Count"
    id: warn_cnt_sensor
    icon: mdi:counter
    accuracy_decimals: 0
    state_class: "total"
    entity_category: "diagnostic" 
  #
  - platform: template
    name: "Log Error Count"
    id: err_cnt_sensor
    icon: mdi:counter
    accuracy_decimals: 0
    state_class: "total"
    entity_category: "diagnostic" 
  #
  - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
    name: "WiFi Signal dB"
    id: wifi_signal_db
#    entity_category: "diagnostic"
  #
  - platform: copy # Reports the WiFi signal strength in %
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "%"
#    entity_category: "diagnostic"

binary_sensor:
  - platform: status
    name: "Living Room AirCon WiFi Status"

switch:
  - platform: template
    name: AirCon Beeper
    icon: mdi:volume-source
    optimistic: true
    restore_state: True
    turn_on_action:
      midea_ac.beeper_on:
    turn_off_action:
      midea_ac.beeper_off:
  - platform: template
    id: follow_room_temp_sw
    name: AirCon Follow Room Temperature
    icon: mdi:home-thermometer
    optimistic: true
    restore_state: True

button:
  - platform: restart
    name: "AirCon WiFi Adapter Restart"    
  - platform: safe_mode
    name: "AirCon WiFi Adapter Restart (Safe Mode)"
    entity_category: "diagnostic"
  - platform: shutdown
    name: "AirCon WiFi Adapter Shutdown"  
    entity_category: "diagnostic"
  - platform: template
    name: AirCon Display Toggle
    icon: mdi:theme-light-dark
    on_press:
      midea_ac.display_toggle:
  - platform: template
    name: AirCon Swing Step
    icon: mdi:tailwind
    on_press:
      midea_ac.swing_step:

# Enable Home Assistant API
api:
  password: !secret api_password
  encryption:
    key: !secret api_key

ota:
  password: !secret ota_password
  id: my_ota

web_server:
  port: 80
  include_internal: true
  local: true
  auth:
    username: !secret web_server_username
    password: !secret web_server_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "SamsungAC Fallback Hotspot"
    password: x

  manual_ip:
    static_ip: x
    gateway: x
    subnet: x
captive_portal:
gedas07 commented 1 year ago

@DjordjeMandic thanks a lot , but i think this is too dificult for me , if the esp-01 don't works for me , i try this but uffffffffffff. :)

DjordjeMandic commented 1 year ago

@gedas07 esp-01 will work, everything is the same in terms of level shifters and etc (you just use esp-01 instead of esp32c3). As far as i remember ac communicates on 5V so one basic level shifter with mosfet is mandatory. IR is needed only for some controls as documented by the esphome component

devmarxx commented 1 year ago

Sorry, you are right! Apart from the ESP8266 ESP-01, I use an Adapter Breakout Board with 3.3V to 5V shifter. That is just plug and play.

s-l1600b

Regards

Chris

gedas07 commented 1 year ago

@DjordjeMandic @devmarxx thanks, yes @devmarxx i buyed one like the photo , it arrives on saturday . Today arrived the esp01 and the flasher , this night i try to flash with esptools or esphome web

gedas07 commented 1 year ago

@DjordjeMandic @devmarxx YESSSSSSSSSS Thank you both very much for all the help you have given me, I have assembled it as you have told me with the esp-01 and the adapter and it works perfectly

very very grateful

gedas07 commented 1 year ago

@devmarxx one question , what is absenkung? that is one switch in your yaml?

devmarxx commented 1 year ago

Good to read that you got it all running :-)

"absenkung" (German. Translated "lowering") is a switch for my python scripts. My scripts lower the target temperature for heating at night automatically. In case I don't want that to happen I can toggle that switch.

Regards

Chris

Edit: "Auto Mode" is also a switch for my scripts.