From 82688cb87403c1954a373de3a6ce20cfa9d931c1 Mon Sep 17 00:00:00 2001 From: aderusha Date: Tue, 26 Dec 2023 14:40:55 -0500 Subject: [PATCH] Add ESPhome configuration --- esphome/haspone.yaml | 75 ++++++++++++++++++++++++++++++++++++++++++++ esphome/readme.md | 3 ++ 2 files changed, 78 insertions(+) create mode 100644 esphome/haspone.yaml create mode 100644 esphome/readme.md diff --git a/esphome/haspone.yaml b/esphome/haspone.yaml new file mode 100644 index 0000000..61b4d3d --- /dev/null +++ b/esphome/haspone.yaml @@ -0,0 +1,75 @@ +# Example ESPhome configuration for use with the HASPone hardware + +substitutions: + device_name: "haspone" + friendly_name: "HASPone hardware for ESPhome" + project_version: "0.0.1" + +esphome: + name: ${device_name} + friendly_name: ${friendly_name} + comment: "http://haswitchplate.com" + project: + name: "esphome.${device_name}" + version: ${project_version} + on_boot: + then: + - switch.turn_on: switch_lcdpower # Power up the Nextion on boot + +esp8266: + board: d1_mini + +logger: + +api: + +ota: + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + +web_server: + port: 80 + +# HASPone switch controls power to the Nextion. Set HIGH at power on to enable the device at boot. +switch: + - platform: gpio + id: switch_lcdpower + name: "${friendly_name} Nextion Power" + pin: D6 #GPIO12 + restore_mode: ALWAYS_ON + internal: false + +# UART for HASPone communication to Nextion. This will utilize software serial and might not work well for TFT updates. +uart: + id: uart_nextion + tx_pin: D4 #GPIO2 + rx_pin: D7 #GPIO13 + baud_rate: 115200 + +# Nextion display device +display: + - platform: nextion + id: display_nextion + uart_id: uart_nextion + on_touch: + then: + lambda: |- + ESP_LOGD("nextion.on_touch", "Nextion touch event detected!"); + ESP_LOGD("nextion.on_touch", "Page Id: %i", page_id); + ESP_LOGD("nextion.on_touch", "Component Id: %i", component_id); + ESP_LOGD("nextion.on_touch", "Event type: %s", touch_event ? "Press" : "Release"); + +# Nextion backlight control +number: + - platform: template + id: number_brightness + name: "${friendly_name} Nextion Brightness" + min_value: 0 + max_value: 100 + step: 1 + initial_value: 100 + optimistic: true + set_action: + - lambda: id(display_nextion)->set_backlight_brightness(x/100); \ No newline at end of file diff --git a/esphome/readme.md b/esphome/readme.md new file mode 100644 index 0000000..e3ffff6 --- /dev/null +++ b/esphome/readme.md @@ -0,0 +1,3 @@ +# HASPone for ESPhome + +Here you'll find an example ESPhome configuration for use with the HASPone hardware, this should be compatible with existing ESPhome-native Nextion projects for a 2.8" panel. \ No newline at end of file