Compare commits

...

16 Commits

Author SHA1 Message Date
GitHub Actions
bd4f6836c9 Bump version to 2024.12.8 [skip-versioning] 2024-12-23 00:14:23 +00:00
Edward Firmo
98ea8810f8 Merge pull request #55 from edwardtfn/relay-on-light-mode
Fix relay on display as light mode
2024-12-23 01:14:09 +01:00
Edward Firmo
552b83f065 Re-add button ids on substitutions 2024-12-23 01:03:51 +01:00
Edward Firmo
ee6f565447 Change refresh to 5min 2024-12-23 00:59:17 +01:00
Edward Firmo
aa4e27ec35 Merge branch 'relay-on-light-mode' of https://github.com/edwardtfn/TX-Ultimate-Easy into relay-on-light-mode 2024-12-23 00:53:37 +01:00
Edward Firmo
8a509cedc8 Point to latest 2024-12-23 00:52:59 +01:00
Edward Firmo
ddea93af6a Merge branch 'main' into relay-on-light-mode 2024-12-23 00:50:29 +01:00
Edward Firmo
dc99319397 Fix relay id on log 2024-12-23 00:46:06 +01:00
Edward Firmo
5ae45fff63 Fix relay on display as light mode
Solves #28
2024-12-23 00:41:51 +01:00
GitHub Actions
bbbaeeb0d4 Bump version to 2024.12.7 [skip-versioning] 2024-12-22 23:02:49 +00:00
Edward Firmo
a9f82d958f Merge pull request #54 from edwardtfn/event-based-automation-docs
Event based automation docs
2024-12-23 00:02:40 +01:00
Edward Firmo
c07e4f195a CodeRabbitAI 2024-12-22 23:55:18 +01:00
Edward Firmo
f1f545198b CodeRabbitAI 2024-12-22 23:47:03 +01:00
Edward Firmo
d87b86bfca CodeRabbitAI 2024-12-22 23:41:02 +01:00
Edward Firmo
f11840d2bc markdownlint 2024-12-22 23:23:22 +01:00
Edward Firmo
42afe71365 Add event based automation overview
Helps with #51
2024-12-22 23:20:39 +01:00
7 changed files with 227 additions and 42 deletions

View File

@@ -26,6 +26,12 @@ substitutions:
BUTTON_PRESS_TIMEOUT: '10000' # Ignore if button is pressed for longer than this time, in msec BUTTON_PRESS_TIMEOUT: '10000' # Ignore if button is pressed for longer than this time, in msec
BUTTON_LONG_PRESS_DELAY: '800' # The time to wait to consider a long press, in msec BUTTON_LONG_PRESS_DELAY: '800' # The time to wait to consider a long press, in msec
# Button numbers constants
BUTTON_1_ID: '1'
BUTTON_2_ID: '2'
BUTTON_3_ID: '3'
BUTTON_4_ID: '4'
binary_sensor: binary_sensor:
- &binary_sensor_button_base - &binary_sensor_button_base
id: bs_button_2 id: bs_button_2

View File

@@ -795,12 +795,12 @@ script:
case 1: case 1:
if (light_index >= id(gb_lights_1).size()) { if (light_index >= id(gb_lights_1).size()) {
ESP_LOGE("core_hw_leds", "Invalid set with %s light for Relay %" PRIu8, ESP_LOGE("core_hw_leds", "Invalid set with %s light for Relay %" PRIu8,
light_mode_group_1.c_str(), light_index); light_mode_group_1.c_str(), light_index+1);
return; return;
} }
if (state and !id(gb_lights_1)[light_index]->current_values.is_on()) { if (state and !id(gb_lights_1)[light_index]->current_values.is_on()) {
ESP_LOGI("core_hw_leds", "Turn-on %s light for Relay %" PRIu8, ESP_LOGI("core_hw_leds", "Turn-on %s light for Relay %" PRIu8,
light_mode_group_1.c_str(), light_index); light_mode_group_1.c_str(), light_index+1);
auto call = id(gb_lights_1)[light_index]->turn_on(); auto call = id(gb_lights_1)[light_index]->turn_on();
if (LIGHT_TRANSITION_TURN_ON > 0) if (LIGHT_TRANSITION_TURN_ON > 0)
call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms
@@ -809,7 +809,7 @@ script:
call.perform(); call.perform();
} else if (!state and id(gb_lights_1)[light_index]->current_values.is_on()) { } else if (!state and id(gb_lights_1)[light_index]->current_values.is_on()) {
ESP_LOGI("core_hw_leds", "Turn-off %s light for Relay %" PRIu8, ESP_LOGI("core_hw_leds", "Turn-off %s light for Relay %" PRIu8,
light_mode_group_1.c_str(), light_index); light_mode_group_1.c_str(), light_index+1);
auto call = id(gb_lights_1)[light_index]->turn_off(); auto call = id(gb_lights_1)[light_index]->turn_off();
if (LIGHT_TRANSITION_TURN_OFF > 0) if (LIGHT_TRANSITION_TURN_OFF > 0)
call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms
@@ -819,12 +819,12 @@ script:
case 2: case 2:
if (light_index >= id(gb_lights_2).size()) { if (light_index >= id(gb_lights_2).size()) {
ESP_LOGE("core_hw_leds", "Invalid set with %s light for Relay %" PRIu8, ESP_LOGE("core_hw_leds", "Invalid set with %s light for Relay %" PRIu8,
light_mode_group_2.c_str(), light_index); light_mode_group_2.c_str(), light_index+1);
return; return;
} }
if (state and !id(gb_lights_2)[light_index]->current_values.is_on()) { if (state and !id(gb_lights_2)[light_index]->current_values.is_on()) {
ESP_LOGI("core_hw_leds", "Turn-on %s light for Relay %" PRIu8, ESP_LOGI("core_hw_leds", "Turn-on %s light for Relay %" PRIu8,
light_mode_group_2.c_str(), light_index); light_mode_group_2.c_str(), light_index+1);
auto call = id(gb_lights_2)[light_index]->turn_on(); auto call = id(gb_lights_2)[light_index]->turn_on();
if (LIGHT_TRANSITION_TURN_ON > 0) if (LIGHT_TRANSITION_TURN_ON > 0)
call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms
@@ -833,7 +833,7 @@ script:
call.perform(); call.perform();
} else if (!state and id(gb_lights_2)[light_index]->current_values.is_on()) { } else if (!state and id(gb_lights_2)[light_index]->current_values.is_on()) {
ESP_LOGI("core_hw_leds", "Turn-off %s light for Relay %" PRIu8, ESP_LOGI("core_hw_leds", "Turn-off %s light for Relay %" PRIu8,
light_mode_group_2.c_str(), light_index); light_mode_group_2.c_str(), light_index+1);
auto call = id(gb_lights_2)[light_index]->turn_off(); auto call = id(gb_lights_2)[light_index]->turn_off();
if (LIGHT_TRANSITION_TURN_OFF > 0) if (LIGHT_TRANSITION_TURN_OFF > 0)
call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms

View File

@@ -11,6 +11,11 @@
##### - For normal system use, modifications to this file are NOT required. ##### ##### - For normal system use, modifications to this file are NOT required. #####
#################################################################################################### ####################################################################################################
--- ---
substitutions:
RELAY_MODE_TEXT_SWITCH: "Switch"
RELAY_MODE_TEXT_LIGHT: "Light"
RELAY_MODE_TEXT_NOT_USED: "Not in use"
globals: globals:
- id: boot_initialization_relays - id: boot_initialization_relays
type: bool type: bool
@@ -19,24 +24,82 @@ globals:
light: light:
# These lights are used for the physical relays to be shown as lights # These lights are used for the physical relays to be shown as lights
- &light_binary_base - id: light_output_1
id: light_output_1
name: Light output 1 name: Light output 1
output: output_relay_1 output: output_relay_1
platform: binary platform: binary
internal: true internal: true
on_turn_on:
then:
- if:
condition:
- switch.is_off: sw_relay_1
then:
- switch.turn_on: sw_relay_1
on_turn_off:
then:
- if:
condition:
- switch.is_on: sw_relay_1
then:
- switch.turn_off: sw_relay_1
- id: light_output_2 - id: light_output_2
name: Light output 2 name: Light output 2
output: output_relay_2 output: output_relay_2
<<: *light_binary_base platform: binary
internal: true
on_turn_on:
then:
- if:
condition:
- switch.is_off: sw_relay_2
then:
- switch.turn_on: sw_relay_2
on_turn_off:
then:
- if:
condition:
- switch.is_on: sw_relay_2
then:
- switch.turn_off: sw_relay_2
- id: light_output_3 - id: light_output_3
name: Light output 3 name: Light output 3
output: output_relay_3 output: output_relay_3
<<: *light_binary_base platform: binary
internal: true
on_turn_on:
then:
- if:
condition:
- switch.is_off: sw_relay_3
then:
- switch.turn_on: sw_relay_3
on_turn_off:
then:
- if:
condition:
- switch.is_on: sw_relay_3
then:
- switch.turn_off: sw_relay_3
- id: light_output_4 - id: light_output_4
name: Light output 4 name: Light output 4
output: output_relay_4 output: output_relay_4
<<: *light_binary_base platform: binary
internal: true
on_turn_on:
then:
- if:
condition:
- switch.is_off: sw_relay_4
then:
- switch.turn_on: sw_relay_4
on_turn_off:
then:
- if:
condition:
- switch.is_on: sw_relay_4
then:
- switch.turn_off: sw_relay_4
output: output:
- id: output_relay_1 - id: output_relay_1
@@ -127,24 +190,20 @@ script:
// Toggle relay if corresponding button action is enabled // Toggle relay if corresponding button action is enabled
switch (button_id) { switch (button_id) {
case 1: case ${BUTTON_1_ID}:
if (sl_button_1_action->active_index().has_value() and if (sl_button_1_action->state != "${RELAY_MODE_TEXT_NOT_USED}")
sl_button_1_action->active_index().value() == 1)
sw_relay_1->toggle(); sw_relay_1->toggle();
break; break;
case 2: case ${BUTTON_2_ID}:
if (sl_button_2_action->active_index().has_value() and if (sl_button_2_action->state != "${RELAY_MODE_TEXT_NOT_USED}")
sl_button_2_action->active_index().value() == 1)
sw_relay_2->toggle(); sw_relay_2->toggle();
break; break;
case 3: case ${BUTTON_3_ID}:
if (sl_button_3_action->active_index().has_value() and if (sl_button_3_action->state != "${RELAY_MODE_TEXT_NOT_USED}")
sl_button_3_action->active_index().value() == 1)
sw_relay_3->toggle(); sw_relay_3->toggle();
break; break;
case 4: case ${BUTTON_4_ID}:
if (sl_button_4_action->active_index().has_value() and if (sl_button_4_action->state != "${RELAY_MODE_TEXT_NOT_USED}")
sl_button_4_action->active_index().value() == 1)
sw_relay_4->toggle(); sw_relay_4->toggle();
break; break;
} }
@@ -226,12 +285,13 @@ script:
select: select:
- &relay_select_mode_base - &relay_select_mode_base
id: sl_relay_1_mode id: sl_relay_1_mode
name: Relay 1 mode name: Relay 1 display mode
platform: template platform: template
options: options:
- "Relay" - "${RELAY_MODE_TEXT_SWITCH}"
- "Light" - "${RELAY_MODE_TEXT_LIGHT}"
- "Not in use" - "${RELAY_MODE_TEXT_NOT_USED}"
initial_option: "${RELAY_MODE_TEXT_SWITCH}"
optimistic: true optimistic: true
restore_value: true restore_value: true
internal: true internal: true
@@ -240,44 +300,107 @@ select:
icon: mdi:dip-switch icon: mdi:dip-switch
- id: sl_relay_2_mode - id: sl_relay_2_mode
name: Relay 2 mode name: Relay 2 display mode
<<: *relay_select_mode_base <<: *relay_select_mode_base
- id: sl_relay_3_mode - id: sl_relay_3_mode
name: Relay 3 mode name: Relay 3 display mode
<<: *relay_select_mode_base <<: *relay_select_mode_base
- id: sl_relay_4_mode - id: sl_relay_4_mode
name: Relay 4 mode name: Relay 4 display mode
<<: *relay_select_mode_base <<: *relay_select_mode_base
switch: switch:
- &relay_switch_base - id: sw_relay_1
id: sw_relay_1
name: Relay 1 name: Relay 1
platform: output
output: output_relay_1 output: output_relay_1
platform: output
restore_mode: RESTORE_DEFAULT_OFF restore_mode: RESTORE_DEFAULT_OFF
internal: true internal: true
on_turn_on: on_turn_on:
then: then:
- script.execute: show_relay_status - script.execute: show_relay_status
- if:
condition:
- light.is_off: light_output_1
then:
light.turn_on: light_output_1
on_turn_off: on_turn_off:
then: then:
- script.execute: show_relay_status - script.execute: show_relay_status
- if:
condition:
- light.is_on: light_output_1
then:
- light.turn_off: light_output_1
- id: sw_relay_2 - id: sw_relay_2
name: Relay 2 name: Relay 2
output: output_relay_2 output: output_relay_2
<<: *relay_switch_base platform: output
restore_mode: RESTORE_DEFAULT_OFF
internal: true
on_turn_on:
then:
- script.execute: show_relay_status
- if:
condition:
- light.is_off: light_output_2
then:
light.turn_on: light_output_2
on_turn_off:
then:
- script.execute: show_relay_status
- if:
condition:
- light.is_on: light_output_2
then:
- light.turn_off: light_output_2
- id: sw_relay_3 - id: sw_relay_3
name: Relay 3 name: Relay 3
output: output_relay_3 output: output_relay_3
<<: *relay_switch_base platform: output
restore_mode: RESTORE_DEFAULT_OFF
internal: true
on_turn_on:
then:
- script.execute: show_relay_status
- if:
condition:
- light.is_off: light_output_3
then:
- light.turn_on: light_output_3
on_turn_off:
then:
- script.execute: show_relay_status
- if:
condition:
- light.is_on: light_output_3
then:
- light.turn_off: light_output_3
- id: sw_relay_4 - id: sw_relay_4
name: Relay 4 name: Relay 4
output: output_relay_4 output: output_relay_4
<<: *relay_switch_base platform: output
restore_mode: RESTORE_DEFAULT_OFF
internal: true
on_turn_on:
then:
- script.execute: show_relay_status
- if:
condition:
- light.is_off: light_output_4
then:
- light.turn_on: light_output_4
on_turn_off:
then:
- script.execute: show_relay_status
- if:
condition:
- light.is_on: light_output_4
then:
- light.turn_off: light_output_4
... ...

View File

@@ -36,7 +36,60 @@ TX Ultimate Easy exposes your device's components (sensors, touch panel, relays,
- Use device triggers and states in your Home Assistant automations and scripts - Use device triggers and states in your Home Assistant automations and scripts
- Configure device behavior through Home Assistant's service calls - Configure device behavior through Home Assistant's service calls
All automation capabilities are handled through Home Assistant's native automation system - this project focuses on providing reliable device integration rather than implementing its own automation tools. All automation capabilities are handled through Home Assistant's native automation system - this project focuses on providing reliable
device integration rather than implementing its own automation tools.
### Event-Based Automation
TX Ultimate Easy uses Home Assistant's native Events system for reliable automation triggers.
While sensors show the current state (e.g., button pressed/not pressed), events capture-specific actions like clicks, swipes, and long presses.
To view available events:
1. Go to Developer Tools in Home Assistant
2. Select the "Events" tab
3. Enter `esphome.tx_ultimate_easy` in the "Event to subscribe to" field
4. Click "Start listening"
5. Interact with your device to see events in real-time
Example event trigger in automation (YAML):
```yaml
triggers:
- platform: event
event_type: esphome.tx_ultimate_easy
event_data:
device_name: your_device_name # Replace with your specific device name
component: bs_button_1 # Button identifier (e.g., bs_button_1, bs_button_2, bs_button_3 or bs_button_4)
event: click
actions:
- action: light.toggle
target:
entity_id: light.living_room
```
**Common event types**:
- `click`: Single press and release
- `double_click`: Two quick presses
- `long_press`: Press and hold
- `swipe_left`: Left swipe gesture
- `swipe_right`: Right swipe gesture
You can also create event-based automations through the Home Assistant UI by selecting "Event" as the trigger type and filtering by your device.
### Device Configuration
#### Relay Modes
- **Light Mode**: Exposes the relay as a light entity with brightness controls (if supported)
- **Switch Mode**: Exposes the relay as a simple on/off switch entity
#### Button Actions
- **None**: Allows using button events for custom automations
Example: Trigger scenes or complex automations through Home Assistant
- **Relay Toggle**: Direct control of the associated relay
Example: Toggle relay state with each press, independent of Home Assistant
#### Automation
All device behaviors can be customized through Home Assistant automations without relying on local device triggers.
## Key Features ## Key Features
@@ -104,6 +157,7 @@ We welcome contributions from the community! Here's how you can help:
4. Submit a pull request targeting the `main` branch 4. Submit a pull request targeting the `main` branch
Please ensure your code follows our standards: Please ensure your code follows our standards:
- Passes all lint checks (YAML, C++, Markdown) - Passes all lint checks (YAML, C++, Markdown)
- Includes appropriate documentation - Includes appropriate documentation
- Follows existing code style - Follows existing code style
@@ -116,7 +170,9 @@ Need help? Here are your options:
- **Community Chat**: Join our [Discord Server](https://discord.gg/Db6WJWzWuf) for discussions and community interaction - **Community Chat**: Join our [Discord Server](https://discord.gg/Db6WJWzWuf) for discussions and community interaction
- **Support the Project**: Consider supporting through Buy Me a Coffee - **Support the Project**: Consider supporting through Buy Me a Coffee
Note: For proper tracking and resolution, all bug reports and feature requests must be submitted through GitHub Issues, not Discord. The Issues page can be found at: [Issues · edwardtfn/TX-Ultimate-Easy](https://github.com/edwardtfn/TX-Ultimate-Easy/issues) Note: For proper tracking and resolution:
- All bug reports and feature requests must be submitted through GitHub Issues, not Discord
- Submit issues here: [Issues · edwardtfn/TX-Ultimate-Easy](https://github.com/edwardtfn/TX-Ultimate-Easy/issues)
[![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://www.buymeacoffee.com/edwardfirmo) [![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://www.buymeacoffee.com/edwardfirmo)

View File

@@ -16,8 +16,8 @@ wifi:
packages: packages:
remote_package: remote_package:
url: https://github.com/edwardtfn/TX-Ultimate-Easy url: https://github.com/edwardtfn/TX-Ultimate-Easy
ref: main ref: latest # Or you can specify a version, like `ref: v2024.12.6`
refresh: 30s refresh: 5min
files: files:
- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml - ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml
# - ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml # Adds experimental BLE proxy support (limited) # - ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml # Adds experimental BLE proxy support (limited)

View File

@@ -1 +1 @@
2024.12.6 2024.12.8

View File

@@ -1 +1 @@
version: 2024.12.6 version: 2024.12.8