fixed syntax, renamed sensors/outputs

This commit is contained in:
Lucas Pleß 2023-10-07 22:19:20 +02:00
parent 9c31f0c96d
commit 26bf7bca5d
1 changed files with 11 additions and 10 deletions

View File

@ -13,7 +13,7 @@ substitutions:
###### nothing to change below this line ###### ###### nothing to change below this line ######
esphome: esphome:
name: $name_of_board name: mlock-${name_of_board}
platform: ESP8266 platform: ESP8266
board: d1_mini board: d1_mini
@ -107,9 +107,9 @@ rc522_spi:
then: then:
- lambda: |- - lambda: |-
json::parse_json(id(http_request_data).get_string(), [](JsonObject root) { json::parse_json(id(http_request_data).get_string(), [](JsonObject root) {
std::string foobar = root["data"]["$name_of_board"]; std::string foobar = root["data"]["mlock-$name_of_board"];
if(foobar == "True") { if(foobar == "True") {
id(switch_output).turn_on(); id(mlock_${name_of_board}_switch).turn_on();
} }
}); });
@ -118,14 +118,14 @@ rc522_spi:
output: output:
- platform: gpio - platform: gpio
pin: D1 pin: D1
id: gpio_relais_output id: mlock_${name_of_board}_gpio_relais_output
# switch component for the output state # switch component for the output state
switch: switch:
- platform: output - platform: output
name: "Relais Output" name: "Relais Output"
id: ${name_of_board}_switch_output id: mlock_${name_of_board}_switch
output: 'gpio_relais_output' output: 'mlock_${name_of_board}_gpio_relais_output'
internal: true # hide from Homeassistant, so no one can turn it on without Tag-Scanning internal: true # hide from Homeassistant, so no one can turn it on without Tag-Scanning
@ -136,15 +136,16 @@ binary_sensor:
number: D3 number: D3
inverted: true inverted: true
mode: INPUT_PULLUP mode: INPUT_PULLUP
id: gpio_input_ausschalter id: ${name_of_board}gpio_input_ausschalter
on_press: on_press:
- switch.turn_off: switch_output - switch.turn_off: mlock_${name_of_board}_switch
# a template sensor for showing the current switch state (read only) # a template sensor for showing the current switch state (read only)
- platform: template - platform: template
id: mlock_${name_of_board}_state_output
name: "${name_of_board} Status Ausgang" name: "${name_of_board} Status Ausgang"
publish_initial_state: true publish_initial_state: true
lambda: |- lambda: |-
return id(switch_output).state; return id(mlock_${name_of_board}_switch).state;
# a button element for Homeassistant UI to allow turning off # a button element for Homeassistant UI to allow turning off
@ -153,7 +154,7 @@ button:
name: "${name_of_board} Ausschalter" name: "${name_of_board} Ausschalter"
id: ${name_of_board}_btn_ausschalter id: ${name_of_board}_btn_ausschalter
on_press: on_press:
- switch.turn_off: switch_output - switch.turn_off: mlock_${name_of_board}_switch