Hellis81
(Hellis81)
1
I have this sensor:
text_sensor:
- platform: nextion
nextion_id: disp1
name: $device_name day
id: disp1_day
component_name: dayt
update_interval: 1s
and in lambda code I want to use this as a integer.
day = id(disp1_day).state;
if(daycount == day){
^^ int value
}
I found this topic but I don’t get it, I can’t get that to work.
Help?
EDIT;
It could probably work the other way around also.
Make daycount a string. daycount is a counter variable in a loop.
Mikefila
(Mike Fila)
2
Does ((toInt(daycount)) == day)
work? Other wise from the sensor that creates daycount
set the value to a global using (toInt(daycount)
in the lambda.
zoogara
(Daryl)
3
Read the linked post in my thread. ESPhome uses character arrays not strings, so your code should look like:
int day = atoi(id(disp1_day).state.c_str());
if(daycount == day){
}
Hellis81
(Hellis81)
4
I could not get atoi or any of the other methods to work.
JBG
(John)
5
Hi there you all …
This worked for me :
it.printf(0, 30, id(OLED_font), "%4.0d W", atoi(id(SolarReading).state.c_str()));