alve89
(Stefan)
December 13, 2021, 7:38am
1
Hi guys,
is there a way to access the value of a global variable of ESPHome via YAML instead of using lambda?
I have two global variables
globals:
- id: totalClick
type: int
restore_value: no
- id: avrPulsePinHelper
type: bool
restore_value: no
I would like to get the values using YAML instead of using lambdas.
Thanks for the help!
ashscott
(Ash)
December 13, 2021, 9:45am
2
For what reason?
Do you want access to the global in HA or just within ESPHome?
alve89
(Stefan)
December 13, 2021, 9:51am
3
Only in ESPHome
ashscott:
For what reason?
Why not? Now I’m realising this with lambda statements, but it’s just interesting for me to know.
It’s also not only access the value but also change it (with something like globals.totalClick.value: 3
)?
Jpsy
(Jörg Wagner)
December 13, 2021, 2:27pm
4
No way. From docs :
In some cases you might require to share a global variable across multiple lambdas .
This is made for Lambdas only.
I want to access esphome globals from HA front end. Can this be done? thx
Mikefila
(Mike Fila)
April 23, 2024, 4:20am
6
No they can’t. They are internal only.
Jpsy
(Jörg Wagner)
April 23, 2024, 5:10am
7
Well, you could create a template sensor in your ESPhome YAML and expose the global as a value of that sensor.