Hello!
I consider myself an ESPHome amateur at this point. I have flashed a few light bulbs and smart outlets with ESPHome using the recommended configurations and now I have a completely from scratch module using a WeMos D1 Mini mostly working.
I keep running into something that I hope someone here can help provide some insight on:
Every time I want to create a component, such as a binary_sensor, switch, button, or text_sensor, that is not connected to a physical thing (i.e. not gpio), I never know what to put in the platform attribute. I end up using “template” and it always seems to work but it seems to be overkill. I understand template to be primarily used with lambdas and I usually don’t need a lambda. I do tend to shy away from lambdas - not because I am afraid of C/C++ - though it has been about 20 years and C and I never got along well anyway , it just seems that it is more direct/more maintainable/less brittle to use existing actions. I know platform: template can be used without a lambda but I was wondering if there is something more appropriate. What I usually want is simply a sensor to hold state and be visible from Home Assistant.
Some examples:
button:
- platform: template
name: "$friendly_name Button 1"
on_press:
then:
- script.execute: openclose_big_gate
Could this ^^^ be something other than template?
Another example (this one I have not solved yet - haven’t figured out how to set the value):
text_sensor:
- platform: template
id: ${id_prefix}_current_action
name: "${friendly_name} Current Action"
I want this to be a short text description of the Action being executed, for example “Activating Big Gate”.
Then in a script that activates the big gate:
script:
- id: openclose_big_gate
then:
- logger.log: "OpenCloseBigGate"
# Don't know what to put here? - text_sensor.${id_prefix}_current_action.set_value: "Activating Big Gate"
- light.turn_on: built_in_led_light
- switch.turn_on: big_gate_relay
# etc...
I am wondering if a platform besides template will make it easier for me to simply set the text value of the sensor at the appropriate time in each script.
Thanks for any assistance!
D