I new to ESPHome, I wish to print the state of a device in the logger.log.
I cannot find the format to use for the state argument.
I try “format: “Hello World is %u”
args: [BuildInLED.state]”
Can anyone help please, this is my first with ESPHome and trying tracing help
Thank you, I also tried about every data type, without a success.
I can see the error message in the log
"src/main.cpp:213:56: error: request for member 'state' in 'BuildInLED', which is of pointer type 'esphome::gpio::GPIOBinaryOutput*' (maybe you meant to use '->' ?)
213 | ESP_LOGD("main", "Hello World is %d", BuildInLED.state);
| ^~~~~"
The main issue is that I don’t know the data type of the device.state.
Preformatted textUsing %f does not compile. It terminate with a fatal error.
light:
- platform: binary
output: "BuildInLED"
name: "Build In LED "
on_state:
logger.log:
format: "Hello World the LED is %0f"
args: [ 'id(BuildInLED).state']
#format: The state of BuildInLED has changed
However when I compile using the commented format: The state……… changed, it compile. And when I turn on/off the LED from Home Assistant it give the state of my device before printing my message.
07:55:09][C][api:143]: Using noise encryption: NO
[07:55:21][D][api:102]: Accepted 10.0.0.35
[07:55:21][D][api.connection:827]: Home Assistant 2022.3.5 (10.0.0.35): Connected successfully
[07:55:26][D][light:035]: 'Build In LED ’ Setting:
[07:55:26][D][light:046]: State: ON
[07:55:26][D][main:211]: The state of BuildInLED has changed
[07:55:31][D][light:035]: 'Build In LED ’ Setting:
[07:55:31][D][light:046]: State: OFF
[07:55:31][D][main:211]: The state of BuildInLED has changed