Split files
To improve readability and increase my chances to have more people collaborating with this project. Solves #27
This commit is contained in:
52
ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml
Normal file
52
ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml
Normal file
@@ -0,0 +1,52 @@
|
||||
####################################################################################################
|
||||
##### TX Ultimate Easy for ESPHome #####
|
||||
##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy #####
|
||||
####################################################################################################
|
||||
##### Purpose: ESPHome Core - API #####
|
||||
####################################################################################################
|
||||
##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo #####
|
||||
####################################################################################################
|
||||
##### NOTE: #####
|
||||
##### - Make changes ONLY if absolutely necessary and you have the required knowledge. #####
|
||||
##### - For normal system use, modifications to this file are NOT required. #####
|
||||
####################################################################################################
|
||||
---
|
||||
api:
|
||||
id: api_server
|
||||
actions:
|
||||
- action: set_float
|
||||
variables:
|
||||
component: string
|
||||
val: float
|
||||
then:
|
||||
- lambda: |-
|
||||
if (!isnan(val)) {
|
||||
if (component == "latitude") sun_entity->set_latitude(val);
|
||||
else if (component == "longitude") sun_entity->set_longitude(val);
|
||||
}
|
||||
|
||||
script:
|
||||
- id: !extend button_action
|
||||
then:
|
||||
- script.execute:
|
||||
id: send_event_to_ha
|
||||
component: !lambda return component.c_str();
|
||||
event: !lambda return event.c_str();
|
||||
|
||||
- id: send_event_to_ha
|
||||
mode: queued
|
||||
parameters:
|
||||
component: string
|
||||
event: string
|
||||
then:
|
||||
- lambda: |-
|
||||
esphome::api::CustomAPIDevice ha_event;
|
||||
ha_event.fire_homeassistant_event("esphome.tx_ultimate_easy",
|
||||
{
|
||||
{"device_name", tx_device_name->state.c_str()},
|
||||
{"firmware", "${version}"},
|
||||
{"component", component},
|
||||
{"event", event},
|
||||
});
|
||||
|
||||
...
|
||||
Reference in New Issue
Block a user