tiimsvk
(Tiimsvk)
August 8, 2022, 7:11pm
1
Hello,
I have created a sensor that merges two separate sensors in the home assistant:
temperature and humidity using the value template:
{{ states('sensor.zadverie_teplomer_esp_temperature_3') | float | round(1)}}/{{ states('sensor.zadverie_teplomer_esp_humidity_3') | float | round(0) }}
I would like to use this data in esphome on the display in two separate lines:
first line temperature
second line humidity
Can you help me with the code? Well thank you.
pepe59
(Pepe59)
August 8, 2022, 7:42pm
2
It depends on which display the values will be displayed
tom_l
August 8, 2022, 9:11pm
3
Why?
Especially as you want to use them separately:
tiimsvk:
Can you help me
Delete your combined sensor.
Add the two sensors to an entities card.
tiimsvk
(Tiimsvk)
August 9, 2022, 3:46am
4
Why?
There are more than 60 sensors that are imported to the display.
ESP32 will not load after a certain amount, but will remain stuck at boot.
Therefore, I need to merge several sensors into one.
nickrout
(Nick Rout)
August 9, 2022, 4:08am
5
What sensible data do you expect to get dividing temp by humidity?
tiimsvk
(Tiimsvk)
August 9, 2022, 4:11am
6
the result from the template is not a division “/” is a character
otherwise, this is the way to write it, which I posted here:
How to reduce the number of characters in a word?
I have an imported calendar from home assistant
I would like to display the time of the event, but only the day and month.
Now the sensor in the start_time attribute shows the following:
start_time: '2022-08-02 00:00:00'
and I would only need to display
'08-02'
I tried the following:
it.printf(it.get_width() - 18, it.get_height(), id(fonttext2), TextAlign::BOTTOM_RIGHT, “%s”, id(calendar_time).state.substr(5, 10).c_str());
But after a …
But there I ran into a problem with “substr”
nickrout
(Nick Rout)
August 9, 2022, 4:17am
7
So right, sorry for the mistake.
tom_l
August 9, 2022, 4:54am
8
I moved your post to the ESPHome category to make it clearer what you are talking about. I missed this:
tiimsvk
(Tiimsvk)
August 9, 2022, 5:08am
9
I solved it this way so far.
Does anyone have an easier entry?
std::string airquality = id(air_spalna).state;
std::size_t temperature_air, humidity_air = 0;
char delimair = '/';
temperature_air = airquality.find(delimair);
for (int k=0; k<2; k++) {
if (k == 0) {
it.printf(87, 204, id(fonttext3), TextAlign::TOP_CENTER, "%s", airquality.substr(humidity_air, temperature_air - humidity_air).c_str());
} else if (k == 1) {
it.printf(87, 216, id(fonttext3), TextAlign::TOP_CENTER, "%s", airquality.substr(humidity_air, temperature_air - humidity_air).c_str());
}
humidity_air = temperature_air + 1;
temperature_air = airquality.find(delimair, humidity_air);
}
Hellis81
(Hellis81)
August 9, 2022, 5:10am
10
You can split a string in two parts I have some code for that but since you have 60 sensor values I suggest you create one sensor with all the values in one attribute as a JSON string.
The entity will probably not look like JSON but if you look in developer tools it is JSON.
Then from there you could probably import it to the ESP device and parse it using:
Solved it! Following code works. It finds third forecast of hourly wind speed, which is 1-2 hours ahead of current time:
(please note that I was getting some crashes on ESP8266, but not on ESP32. Seems to be memory problem)
sensor:
- platform: template
name: "Predicted wind"
id: predicted_wind
http_request:
useragent: esphome/device
timeout: 10s
time:
- platform: sntp
on_time:
- seconds: 0
minutes: /15
then:
- lambda: |-
HTTPC…