From 64e46640322b1a636a8b5716fd75e03c4bba5292 Mon Sep 17 00:00:00 2001 From: Eric Chavet Date: Mon, 20 Jan 2025 14:51:14 +0100 Subject: [PATCH 1/3] Create Readme.md --- atoms3/Readme.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 atoms3/Readme.md diff --git a/atoms3/Readme.md b/atoms3/Readme.md new file mode 100644 index 0000000..b0ebccb --- /dev/null +++ b/atoms3/Readme.md @@ -0,0 +1,7 @@ +# atoms3 configuration example +this directory contains an example of a tested configuration firmware for controling a Mitsubishi cooling unit via CN105. + +Here is the discussion link: +https://github.com/echavet/MitsubishiCN105ESPHome/discussions/83 + +![Picture of an atom S3 ship mounted on a unit.](https://github.com/echavet/atoms3/blob/main/IMG_5664.jpg) From e4487d2963e40b42015e35e018c708e2bca92ee3 Mon Sep 17 00:00:00 2001 From: Eric Chavet Date: Mon, 20 Jan 2025 14:52:58 +0100 Subject: [PATCH 2/3] Add files via upload --- atoms3/atom-m5.yaml | 46 ++++++++++ atoms3/includes/api-config.yaml | 18 ++++ atoms3/includes/binary-sensor-config.yaml | 38 ++++++++ atoms3/includes/bt-proxy-config.yaml | 14 +++ atoms3/includes/climate-config.yaml | 54 +++++++++++ atoms3/includes/diag-sensor-config.yaml | 102 +++++++++++++++++++++ atoms3/includes/display_config.yaml | 86 +++++++++++++++++ atoms3/includes/fonts.yaml | 13 +++ atoms3/includes/ha-integration-config.yaml | 19 ++++ atoms3/includes/mqtt-config.yaml | 5 + atoms3/includes/wifi-config.yaml | 19 ++++ 11 files changed, 414 insertions(+) create mode 100644 atoms3/atom-m5.yaml create mode 100644 atoms3/includes/api-config.yaml create mode 100644 atoms3/includes/binary-sensor-config.yaml create mode 100644 atoms3/includes/bt-proxy-config.yaml create mode 100644 atoms3/includes/climate-config.yaml create mode 100644 atoms3/includes/diag-sensor-config.yaml create mode 100644 atoms3/includes/display_config.yaml create mode 100644 atoms3/includes/fonts.yaml create mode 100644 atoms3/includes/ha-integration-config.yaml create mode 100644 atoms3/includes/mqtt-config.yaml create mode 100644 atoms3/includes/wifi-config.yaml diff --git a/atoms3/atom-m5.yaml b/atoms3/atom-m5.yaml new file mode 100644 index 0000000..cccf9fa --- /dev/null +++ b/atoms3/atom-m5.yaml @@ -0,0 +1,46 @@ +substitutions: + name: "atom-s3" + friendly_name: "M5Stack Atom S3 bt proxy + cn105" + clim_name: Clim Sejour + +esphome: + name: ${name} + friendly_name: ${friendly_name} + min_version: 2024.6.0 + name_add_mac_suffix: true + project: + name: esphome.clim_and_nt_proxy + version: "24.7.4.1" + +debug: + update_interval: 5s + +# Enable logging +logger: + #hardware_uart: USB_CDC + level: INFO + +esp32: + board: esp32-s3-devkitc-1 + + #board: m5stack-cores3 + #variant: ESP32S3 + framework: + type: arduino + #type: esp-idf + version: recommended + flash_size: 8MB + +# mqtt, api, ota, wifi, captive, web, time +<<: !include includes/ha-integration-config.yaml + +# display button and api status binary_sensor configuration +<<: !include includes/binary-sensor-config.yaml + +# displays infos on atom screen +<<: !include includes/display_config.yaml +# configure esp bluetooth proxy +<<: !include includes/bt-proxy-config.yaml + +# cn105 mitsubishi climate config +<<: !include includes/climate-config.yaml diff --git a/atoms3/includes/api-config.yaml b/atoms3/includes/api-config.yaml new file mode 100644 index 0000000..180455b --- /dev/null +++ b/atoms3/includes/api-config.yaml @@ -0,0 +1,18 @@ +services: + - service: reboot + then: + - logger.log: "Redémarrage en cours..." + - lambda: |- + esp_restart(); + - service: set_remote_temperature + variables: + temperature: float + then: + - lambda: 'id(atoms3_clim).set_remote_temperature(temperature);' + + - service: use_internal_temperature + then: + - lambda: 'id(atoms3_clim).set_remote_temperature(0);' + +encryption: + key: !secret encryption_key \ No newline at end of file diff --git a/atoms3/includes/binary-sensor-config.yaml b/atoms3/includes/binary-sensor-config.yaml new file mode 100644 index 0000000..39d19d7 --- /dev/null +++ b/atoms3/includes/binary-sensor-config.yaml @@ -0,0 +1,38 @@ +binary_sensor: + - platform: status + name: "Home Assistant API Connection" + id: ha_api_status + + - platform: gpio + name: Button + pin: + number: GPIO41 + inverted: true + mode: + input: true + pullup: true + filters: + - delayed_off: 10ms + + on_click: + - min_length: 10ms + max_length: 350ms + then: + - logger.log: Button short click + # - display_menu.show: test_graphical_display_menu + - lambda: |- + id(current_page)++; + if (id(current_page) >= 3) { // Nombre de pages (index 0 et 1 dans cet exemple) + id(current_page) = 0; + } + if (id(current_page) == 0) { + id(display_tft).show_page(id(page1)); + } else if (id(current_page) == 1) { + id(display_tft).show_page(id(page2)); + } else if (id(current_page) == 2) { + id(display_tft).show_page(id(page3)); + } + - min_length: 350ms + max_length: 4000ms + then: + - logger.log: Button long click \ No newline at end of file diff --git a/atoms3/includes/bt-proxy-config.yaml b/atoms3/includes/bt-proxy-config.yaml new file mode 100644 index 0000000..54df500 --- /dev/null +++ b/atoms3/includes/bt-proxy-config.yaml @@ -0,0 +1,14 @@ +remote_transmitter: + pin: GPIO4 + carrier_duty_percent: 50% + + +esp32_ble_tracker: + scan_parameters: + # We currently use the defaults to ensure Bluetooth + # can co-exist with WiFi In the future we may be able to + # enable the built-in coexistence logic in ESP-IDF + active: true + +bluetooth_proxy: + active: true \ No newline at end of file diff --git a/atoms3/includes/climate-config.yaml b/atoms3/includes/climate-config.yaml new file mode 100644 index 0000000..b0cc13b --- /dev/null +++ b/atoms3/includes/climate-config.yaml @@ -0,0 +1,54 @@ +# includes diagnostic sensors +<<: !include diag-sensor-config.yaml + +external_components: + - source: github://echavet/MitsubishiCN105ESPHome + refresh: 0s +uart: + id: HP_UART + baud_rate: 2400 + tx_pin: GPIO01 #G1 + rx_pin: GPIO02 #G2 +climate: + - platform: cn105 + name: ${clim_name} + id: "atoms3_clim" + compressor_frequency_sensor: + name: Compressor frequency (clim Sejour) + input_power_sensor: + name: Input power + kwh_sensor: + name: Energy usage + runtime_hours_sensor: + name: Runtime hours + + outside_air_temperature_sensor: + name: ${name} Outside air temperature + vertical_vane_select: + name: Orientation de la Vane Verticale + horizontal_vane_select: + name: Orientation de la Vane Horizontale + isee_sensor: + name: ISEE Sensor + auto_sub_mode_sensor: + name: auto-submode sensor + sub_mode_sensor: + name: submode sensor + stage_sensor: + name: stage sensor + remote_temperature_timeout: 15min + update_interval: 2300ms # shouldn't be less than 1 second + debounce_delay: 100ms # delay to prevent bouncing + hp_uptime_connection_sensor: + name: ${name} HP Uptime Connection + update_interval: 10s + supports: + mode: [COOL, HEAT, FAN_ONLY, DRY] + fan_mode: [AUTO, QUIET, LOW, MEDIUM, HIGH] + swing_mode: ["OFF", VERTICAL] + visual: + min_temperature: 17 + max_temperature: 28 + temperature_step: + target_temperature: 0.5 + current_temperature: 0.1 diff --git a/atoms3/includes/diag-sensor-config.yaml b/atoms3/includes/diag-sensor-config.yaml new file mode 100644 index 0000000..f0145e5 --- /dev/null +++ b/atoms3/includes/diag-sensor-config.yaml @@ -0,0 +1,102 @@ + +sensor: + # # Sensors with general information. + - platform: template + name: "dg_uart_connected" + entity_category: DIAGNOSTIC + lambda: |- + return (bool) id(atoms3_clim).isUARTConnected_; + update_interval: 30s + + - platform: template + name: "dg_complete_cycles" + entity_category: DIAGNOSTIC + accuracy_decimals: 0 + lambda: |- + return (unsigned long) id(atoms3_clim).nbCompleteCycles_; + update_interval: 60s + + - platform: template + name: "dg_total_cycles" + accuracy_decimals: 0 + entity_category: DIAGNOSTIC + lambda: |- + return (unsigned long) id(atoms3_clim).nbCycles_; + update_interval: 60s + - platform: template + name: "dg_nb_hp_connections" + accuracy_decimals: 0 + entity_category: DIAGNOSTIC + lambda: |- + return (unsigned int) id(atoms3_clim).nbHeatpumpConnections_; + update_interval: 60s + + - platform: template + name: "dg_complete_cycles_percent" + id: complete_cycles_percent + unit_of_measurement: "%" + accuracy_decimals: 1 + entity_category: DIAGNOSTIC + lambda: |- + unsigned long nbCompleteCycles = id(atoms3_clim).nbCompleteCycles_; + unsigned long nbCycles = id(atoms3_clim).nbCycles_; + if (nbCycles == 0) { + return 0.0; + } + return (float) nbCompleteCycles / nbCycles * 100.0; + update_interval: 60s + + - platform: debug + free: + name: "Heap Free" + # fragmentation: + # name: "Heap Fragmentation" + # block: + # name: "Heap Max Block" + # loop_time: + # name: "Loop Time" + # psram: + # name: "Free PSRAM" + + + # Uptime sensor. + - platform: uptime + name: ${name} Uptime + + # WiFi Signal sensor. + - platform: wifi_signal + id: wifi_signal_dbm + name: ${name} WiFi Signal + update_interval: 60s + + - platform: homeassistant + id: ha_cdeg_sejour_et_cuisine + entity_id: sensor.temperature_sejour + internal: true + on_value: + then: + - lambda: |- + id(atoms3_clim).set_remote_temperature(x); + + +text_sensor: + # Expose ESPHome version as sensor. + - platform: version + name: ${name} ESPHome Version + # Expose WiFi information as sensors. + - platform: wifi_info + ip_address: + name: ${name} IP + id: wifi_ip # ID pour référence dans l'écran + ssid: + name: ${name} SSID + id: wifi_ssid # ID pour référence dans l'écran + bssid: + name: ${name} BSSID + id: wifi_bssid # ID pour référence dans l'écran + + - platform: debug + device: + name: "Device Info" + reset_reason: + name: "Reset Reason" \ No newline at end of file diff --git a/atoms3/includes/display_config.yaml b/atoms3/includes/display_config.yaml new file mode 100644 index 0000000..77bede5 --- /dev/null +++ b/atoms3/includes/display_config.yaml @@ -0,0 +1,86 @@ +globals: + - id: current_page + type: "int" + initial_value: "0" + +font: !include fonts.yaml + +spi: + clk_pin: 17 + mosi_pin: 21 + +display: + - platform: st7789v + id: display_tft + model: Custom + height: 128 + width: 128 + rotation: 0 + offset_height: 2 + offset_width: 1 + backlight_pin: 16 + cs_pin: 15 + dc_pin: 33 #RS/DC + reset_pin: 34 + eightbitcolor: true + update_interval: 05s + pages: + - id: page1 + lambda: |- + Color color_orange(255, 165, 0); + Color color_blue(0, 0, 255); + Color color_yellow(255, 255, 0); + Color color_black(0, 0, 0); + + // Changer la couleur de fond en fonction du mode du climatiseur + if (id(atoms3_clim).mode == esphome::climate::CLIMATE_MODE_HEAT) { + it.fill(color_orange); + } else if (id(atoms3_clim).mode == esphome::climate::CLIMATE_MODE_COOL) { + it.fill(color_blue); + } else if (id(atoms3_clim).mode == esphome::climate::CLIMATE_MODE_FAN_ONLY) { + it.fill(color_yellow); + } else { + it.fill(color_black); + } + + // Afficher la température de consigne en grand texte + it.printf(it.get_width() / 2, it.get_height() / 2 - 10, id(font_display), TextAlign::CENTER, "%.1f °C", id(atoms3_clim).target_temperature); + + // Afficher la température de la pièce en texte plus petit en dessous + it.printf(it.get_width() / 2, it.get_height() / 2 + 32, id(font_data), TextAlign::CENTER, "%.1f °C", id(atoms3_clim).current_temperature); + + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + it.print(2, 2, id(font_title), "WiFi:"); + // En-tête pour l'IP + it.print(2, 22, id(font_header), "IP:"); + // Donnée pour l'IP + it.print(2, 34, id(font_data), id(wifi_ip).state.c_str()); + + // En-tête pour le SSID + it.print(2, 54, id(font_header), "SSID:"); + // Donnée pour le SSID + it.print(2, 66, id(font_data), id(wifi_ssid).state.c_str()); + + // En-tête pour le BSSID + it.print(2, 86, id(font_header), "BSSID:"); + // Donnée pour le BSSID + it.print(2, 98, id(font_data), id(wifi_bssid).state.c_str()); + it.printf(2, 112, id(font_header), "signal: %.1f dBm", id(wifi_signal_dbm).state); + + - id: page3 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + // Section HA Integration + it.print(2, 2, id(font_title), "HA Integration:"); + it.strftime(12, 22, id(font_data), "%H:%M:%S", id(ha_time).now()); + it.print(12, 36, id(font_data), "API & MQTT"); + it.printf(16, 48, id(font_data), "Status: %s", id(ha_api_status).state?"OK":"FAILED"); + + + // Section Climate UART + it.print(2, 66, id(font_title), "Climate UART:"); + it.print(2, 87, id(font_data), "Successful cycles:"); + it.printf(12, 100, id(font_data), "%.1f%%", id(complete_cycles_percent).state); diff --git a/atoms3/includes/fonts.yaml b/atoms3/includes/fonts.yaml new file mode 100644 index 0000000..ef6d920 --- /dev/null +++ b/atoms3/includes/fonts.yaml @@ -0,0 +1,13 @@ + +- file: "gfonts://Roboto" + id: font_header + size: 14 +- file: "gfonts://Roboto" + id: font_data + size: 12 +- file: "gfonts://Roboto" + id: font_title + size: 18 +- file: "gfonts://Roboto" + id: font_display + size: 30 \ No newline at end of file diff --git a/atoms3/includes/ha-integration-config.yaml b/atoms3/includes/ha-integration-config.yaml new file mode 100644 index 0000000..c6e288c --- /dev/null +++ b/atoms3/includes/ha-integration-config.yaml @@ -0,0 +1,19 @@ +mqtt: !include mqtt-config.yaml +api: !include api-config.yaml + +ota: + - platform: esphome + password: !secret ota_pwd + +wifi: !include wifi-config.yaml + +captive_portal: + +improv_serial: + +web_server: + port: 80 + +time: + platform: homeassistant + id: ha_time diff --git a/atoms3/includes/mqtt-config.yaml b/atoms3/includes/mqtt-config.yaml new file mode 100644 index 0000000..09d50d3 --- /dev/null +++ b/atoms3/includes/mqtt-config.yaml @@ -0,0 +1,5 @@ +#broker: home-io.local +broker: !secret broker +username: !secret m5_login +password: !secret m5_password +discovery: true \ No newline at end of file diff --git a/atoms3/includes/wifi-config.yaml b/atoms3/includes/wifi-config.yaml new file mode 100644 index 0000000..cc46bad --- /dev/null +++ b/atoms3/includes/wifi-config.yaml @@ -0,0 +1,19 @@ +#use_address: 10.1.101.172 +#use_address: 192.168.8.109 +networks: +- ssid: !secret wifi_ssid + password: !secret wifi_password +- ssid : !secret wifi_ssid2 + password: !secret wifi_password2 +- ssid : !secret wifi_ssid3 + password: !secret wifi_password3 +- ssid : !secret wifi_ssid4 + password: !secret wifi_password4 + +#- ssid: !secret wifi_ssid2 +# password: !secret wifi_password2 + +# Enable fallback hotspot (captive portal) in case wifi connection fails +ap: + ssid: "atom Fallback Hotspot" + password: !secret ota_pwd From 59091d31491e66f11159bfcde0e200bbb2b647cb Mon Sep 17 00:00:00 2001 From: Eric Chavet Date: Mon, 20 Jan 2025 14:55:41 +0100 Subject: [PATCH 3/3] Update Readme.md --- atoms3/Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/atoms3/Readme.md b/atoms3/Readme.md index b0ebccb..a6a2eee 100644 --- a/atoms3/Readme.md +++ b/atoms3/Readme.md @@ -1,5 +1,6 @@ # atoms3 configuration example this directory contains an example of a tested configuration firmware for controling a Mitsubishi cooling unit via CN105. +Please note that, as an example too, this config includes the bt-proxy. This allows me to control my Gardena Irrigation Vane thanks to its proximity to the unit. Here is the discussion link: https://github.com/echavet/MitsubishiCN105ESPHome/discussions/83