Support to ESPHome 2025.7.0
- Resolve duplicated names - Rebuilt HA event calls
This commit is contained in:
@@ -17,6 +17,8 @@ substitutions:
|
||||
|
||||
<<: !include ../versioning/VERSION_YAML
|
||||
|
||||
EVENT_NAME: esphome.tx_ultimate_easy
|
||||
|
||||
TX_MODEL_FORMAT_EU_TEXT: "EU (Square, T5-xC-86)"
|
||||
TX_MODEL_FORMAT_US_TEXT: "US (Rectangle, T5-xC-120)"
|
||||
|
||||
@@ -116,13 +118,15 @@ script:
|
||||
parameters:
|
||||
type: string
|
||||
then:
|
||||
- homeassistant.event:
|
||||
event: esphome.tx_ultimate_easy
|
||||
data:
|
||||
device_name: !lambda return tx_device_name->state.c_str();
|
||||
firmware: ${version}
|
||||
domain: boot
|
||||
type: !lambda return type.c_str();
|
||||
- lambda: |-
|
||||
// Send event to Home Assistant
|
||||
esphome::api::CustomAPIDevice ha_event;
|
||||
ha_event.fire_homeassistant_event("${EVENT_NAME}", {
|
||||
{"device_name", id(tx_device_name).state.c_str()},
|
||||
{"firmware", "${version}"},
|
||||
{"domain", "boot"},
|
||||
{"type", type.c_str()}
|
||||
});
|
||||
|
||||
- id: boot_done
|
||||
mode: restart
|
||||
|
||||
@@ -112,18 +112,19 @@ script:
|
||||
action: string
|
||||
count: uint8_t
|
||||
then:
|
||||
- homeassistant.event:
|
||||
event: esphome.tx_ultimate_easy
|
||||
data:
|
||||
device_name: !lambda return tx_device_name->state.c_str();
|
||||
firmware: ${version}
|
||||
domain: touch
|
||||
type: button
|
||||
action: !lambda return action.c_str();
|
||||
button_id: !lambda return button;
|
||||
count: !lambda return count;
|
||||
position: !lambda return id(button_press_position);
|
||||
- lambda: |-
|
||||
// Send event to Home Assistant
|
||||
esphome::api::CustomAPIDevice ha_event;
|
||||
ha_event.fire_homeassistant_event("${EVENT_NAME}", {
|
||||
{"device_name", id(tx_device_name).state.c_str()},
|
||||
{"firmware", "${version}"},
|
||||
{"domain", "touch"},
|
||||
{"type", "button"},
|
||||
{"action", action.c_str()},
|
||||
{"button_id", to_string(button)},
|
||||
{"count", to_string(count)},
|
||||
{"position", to_string(id(button_press_position))}
|
||||
});
|
||||
ESP_LOGI("core_hw_buttons", "Button %" PRIu8 " action: '%s'", button, action.c_str());
|
||||
if (action == "click") {
|
||||
switch (button) {
|
||||
|
||||
@@ -57,7 +57,7 @@ light:
|
||||
# Those lights are available based on the model selections
|
||||
- &light_partition_with_effects
|
||||
id: light_eu
|
||||
name: Light
|
||||
name: Light EU
|
||||
platform: partition
|
||||
default_transition_length: ${default_transition_length}
|
||||
internal: true
|
||||
@@ -106,7 +106,7 @@ light:
|
||||
to: 27
|
||||
|
||||
- id: light_us
|
||||
name: Light
|
||||
name: Light US
|
||||
<<: *light_partition_with_effects
|
||||
segments:
|
||||
- id: light_full
|
||||
@@ -115,7 +115,7 @@ light:
|
||||
|
||||
- &light_partition_with_effects_disabled
|
||||
id: light_eu_bottom
|
||||
name: Light - Bottom
|
||||
name: Light - Bottom EU
|
||||
disabled_by_default: true
|
||||
<<: *light_partition_with_effects
|
||||
segments:
|
||||
@@ -124,7 +124,7 @@ light:
|
||||
to: 12
|
||||
reversed: true
|
||||
- id: light_eu_left
|
||||
name: Light - Left
|
||||
name: Light - Left EU
|
||||
<<: *light_partition_with_effects_disabled
|
||||
segments:
|
||||
- id: light_full
|
||||
@@ -132,7 +132,7 @@ light:
|
||||
to: 19
|
||||
reversed: true
|
||||
- id: light_eu_right
|
||||
name: Light - Right
|
||||
name: Light - Right EU
|
||||
<<: *light_partition_with_effects_disabled
|
||||
segments:
|
||||
- id: light_full
|
||||
@@ -144,7 +144,7 @@ light:
|
||||
to: 5
|
||||
reversed: false
|
||||
- id: light_eu_top
|
||||
name: Light - Top
|
||||
name: Light - Top EU
|
||||
<<: *light_partition_with_effects_disabled
|
||||
segments:
|
||||
- id: light_full
|
||||
@@ -152,7 +152,7 @@ light:
|
||||
to: 26
|
||||
reversed: false
|
||||
- id: light_us_bottom
|
||||
name: Light - Bottom
|
||||
name: Light - Bottom US
|
||||
<<: *light_partition_with_effects_disabled
|
||||
segments:
|
||||
- id: light_full
|
||||
@@ -160,7 +160,7 @@ light:
|
||||
to: 14
|
||||
reversed: true
|
||||
- id: light_us_left
|
||||
name: Light - Left
|
||||
name: Light - Left US
|
||||
<<: *light_partition_with_effects_disabled
|
||||
segments:
|
||||
- id: light_full
|
||||
@@ -168,7 +168,7 @@ light:
|
||||
to: 24
|
||||
reversed: true
|
||||
- id: light_us_right
|
||||
name: Light - Right
|
||||
name: Light - Right US
|
||||
<<: *light_partition_with_effects_disabled
|
||||
segments:
|
||||
- id: light_full
|
||||
@@ -180,7 +180,7 @@ light:
|
||||
to: 8
|
||||
reversed: false
|
||||
- id: light_us_top
|
||||
name: Light - Top
|
||||
name: Light - Top US
|
||||
<<: *light_partition_with_effects_disabled
|
||||
segments:
|
||||
- id: light_full
|
||||
@@ -567,7 +567,7 @@ select:
|
||||
# EU relay light mode template
|
||||
- &relay_light_mode_eu
|
||||
id: sl_relay_1_light_mode_eu
|
||||
name: Relay 1 light mode
|
||||
name: Relay 1 light mode EU
|
||||
platform: template
|
||||
options:
|
||||
- "${LIGHT_MODE_DISABLED_TEXT}"
|
||||
@@ -582,19 +582,19 @@ select:
|
||||
disabled_by_default: false
|
||||
icon: mdi:dots-square
|
||||
- id: sl_relay_2_light_mode_eu
|
||||
name: Relay 2 light mode
|
||||
name: Relay 2 light mode EU
|
||||
<<: *relay_light_mode_eu
|
||||
- id: sl_relay_3_light_mode_eu
|
||||
name: Relay 3 light mode
|
||||
name: Relay 3 light mode EU
|
||||
<<: *relay_light_mode_eu
|
||||
- id: sl_relay_4_light_mode_eu
|
||||
name: Relay 4 light mode
|
||||
name: Relay 4 light mode EU
|
||||
<<: *relay_light_mode_eu
|
||||
|
||||
# US relay light mode template
|
||||
- &relay_light_mode_us
|
||||
id: sl_relay_1_light_mode_us
|
||||
name: Relay 1 light mode
|
||||
name: Relay 1 light mode US
|
||||
platform: template
|
||||
options:
|
||||
- "${LIGHT_MODE_DISABLED_TEXT}"
|
||||
@@ -609,12 +609,12 @@ select:
|
||||
disabled_by_default: false
|
||||
icon: mdi:dots-square
|
||||
- id: sl_relay_2_light_mode_us
|
||||
name: Relay 2 light mode
|
||||
name: Relay 2 light mode US
|
||||
<<: *relay_light_mode_us
|
||||
- id: sl_relay_3_light_mode_us
|
||||
name: Relay 3 light mode
|
||||
name: Relay 3 light mode US
|
||||
<<: *relay_light_mode_us
|
||||
- id: sl_relay_4_light_mode_us
|
||||
name: Relay 4 light mode
|
||||
name: Relay 4 light mode US
|
||||
<<: *relay_light_mode_us
|
||||
...
|
||||
|
||||
@@ -386,69 +386,74 @@ tx_ultimate_easy:
|
||||
}
|
||||
|
||||
on_multi_touch_release:
|
||||
- homeassistant.event:
|
||||
event: esphome.tx_ultimate_easy
|
||||
data:
|
||||
device_name: !lambda return tx_device_name->state.c_str();
|
||||
firmware: ${version}
|
||||
domain: touch
|
||||
type: multi_touch
|
||||
action: release
|
||||
position: !lambda return touch.x;
|
||||
- lambda: ESP_LOGI("core_hw_touch", "Multi-touch released");
|
||||
- script.execute: touch_on_multi_touch_release
|
||||
then:
|
||||
- lambda: |-
|
||||
// Send event to Home Assistant
|
||||
esphome::api::CustomAPIDevice ha_event;
|
||||
ha_event.fire_homeassistant_event("${EVENT_NAME}", {
|
||||
{"device_name", id(tx_device_name).state.c_str()},
|
||||
{"firmware", "${version}"},
|
||||
{"domain", "touch"},
|
||||
{"type", "multi_touch"},
|
||||
{"action", "release"},
|
||||
{"position", to_string(touch.x)}
|
||||
});
|
||||
ESP_LOGI("core_hw_touch", "Multi-touch released");
|
||||
touch_on_multi_touch_release->execute();
|
||||
|
||||
on_press:
|
||||
- lambda: |-
|
||||
const uint8_t position = static_cast<uint8_t>(touch.x);
|
||||
if (position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range
|
||||
ESP_LOGE("core_hw_touch", "Invalid touch position: %" PRIu8, position);
|
||||
} else {
|
||||
ESP_LOGI("core_hw_touch", "Pressed at position %" PRIu8, position);
|
||||
touch_on_press->execute(static_cast<uint8_t>(touch.button), position);
|
||||
}
|
||||
then:
|
||||
- lambda: |-
|
||||
const uint8_t position = static_cast<uint8_t>(touch.x);
|
||||
if (position > ${TOUCH_POSITION_MAX_VALUE}) { // Check for valid range
|
||||
ESP_LOGE("core_hw_touch", "Invalid touch position: %" PRIu8, position);
|
||||
} else {
|
||||
ESP_LOGI("core_hw_touch", "Pressed at position %" PRIu8, position);
|
||||
touch_on_press->execute(static_cast<uint8_t>(touch.button), position);
|
||||
}
|
||||
|
||||
on_release:
|
||||
- lambda: ESP_LOGI("core_hw_touch", "Released");
|
||||
- script.execute: touch_on_release
|
||||
then:
|
||||
- lambda: ESP_LOGI("core_hw_touch", "Released");
|
||||
- script.execute: touch_on_release
|
||||
|
||||
on_swipe_left:
|
||||
- homeassistant.event:
|
||||
event: esphome.tx_ultimate_easy
|
||||
data:
|
||||
device_name: !lambda return tx_device_name->state.c_str();
|
||||
firmware: ${version}
|
||||
domain: touch
|
||||
type: swipe
|
||||
action: !lambda |-
|
||||
return sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}" ? "left" : "down";
|
||||
swipe-direction: !lambda |-
|
||||
return sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}" ? "left" : "down";
|
||||
position: !lambda return touch.x;
|
||||
- lambda: |-
|
||||
ESP_LOGI("core_hw_touch", "Swipe %s", sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}"
|
||||
? "left"
|
||||
: "down");
|
||||
- script.execute: touch_swipe_left
|
||||
then:
|
||||
- lambda: |-
|
||||
std::string swipe_direction = (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "left" : "down";
|
||||
// Send event to Home Assistant
|
||||
esphome::api::CustomAPIDevice ha_event;
|
||||
ha_event.fire_homeassistant_event("${EVENT_NAME}", {
|
||||
{"device_name", id(tx_device_name).state.c_str()},
|
||||
{"firmware", "${version}"},
|
||||
{"domain", "touch"},
|
||||
{"type", "swipe"},
|
||||
{"action", swipe_direction.c_str()},
|
||||
{"swipe-direction", swipe_direction.c_str()},
|
||||
{"position", to_string(touch.x)}
|
||||
});
|
||||
ESP_LOGI("core_hw_touch", "Multi-touch released");
|
||||
touch_on_multi_touch_release->execute();
|
||||
ESP_LOGI("core_hw_touch", "Swipe %s", swipe_direction.c_str());
|
||||
touch_swipe_left->execute();
|
||||
|
||||
on_swipe_right:
|
||||
- homeassistant.event:
|
||||
event: esphome.tx_ultimate_easy
|
||||
data:
|
||||
device_name: !lambda return tx_device_name->state.c_str();
|
||||
firmware: ${version}
|
||||
domain: touch
|
||||
type: swipe
|
||||
action: !lambda |-
|
||||
return sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}" ? "right" : "up";
|
||||
swipe-direction: !lambda |-
|
||||
return sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}" ? "right" : "up";
|
||||
position: !lambda return touch.x;
|
||||
- lambda: |-
|
||||
ESP_LOGI("core_hw_touch", "Swipe %s", sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}"
|
||||
? "right"
|
||||
: "up");
|
||||
- script.execute: touch_swipe_right
|
||||
then:
|
||||
- lambda: |-
|
||||
std::string swipe_direction = (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "right" : "up";
|
||||
// Send event to Home Assistant
|
||||
esphome::api::CustomAPIDevice ha_event;
|
||||
ha_event.fire_homeassistant_event("${EVENT_NAME}", {
|
||||
{"device_name", id(tx_device_name).state.c_str()},
|
||||
{"firmware", "${version}"},
|
||||
{"domain", "touch"},
|
||||
{"type", "swipe"},
|
||||
{"action", swipe_direction.c_str()},
|
||||
{"swipe-direction", swipe_direction.c_str()},
|
||||
{"position", to_string(touch.x)}
|
||||
});
|
||||
ESP_LOGI("core_hw_touch", "Swipe %s", swipe_direction.c_str());
|
||||
touch_swipe_right->execute();
|
||||
|
||||
on_touch_event:
|
||||
- lambda: |-
|
||||
|
||||
Reference in New Issue
Block a user