[15:42:03.792][I][main:051]: Global value: 10
[15:42:06.795][I][main:051]: Global value: 10
[15:42:09.796][I][main:051]: Global value: 10
[15:42:12.797][I][main:051]: Global value: 10
[15:42:15.798][I][main:051]: Global value: 10
[15:42:18.800][I][main:051]: Global value: 10
[15:42:21.801][I][main:051]: Global value: 10
[15:42:24.800][I][main:051]: Global value: 10
[15:42:27.801][I][main:051]: Global value: 10
[15:42:30.802][I][main:051]: Global value: 10
[15:42:33.803][I][main:051]: Global value: 10
[15:42:36.803][I][main:051]: Global value: 10
[15:42:39.806][I][main:051]: Global value: 10
[15:42:42.812][I][main:051]: Global value: 10
[15:42:45.818][I][main:051]: Global value: 10
@Hellis81 thank you for the explanation, there is still much I do not understand of EspHome, could you share how the code would look like? So maybe I can finally make it work
As Hellis initially mentioned, you shouldn’t normally need to use a global or an input_helper.
All your ESPHome components are shown on the HA > settings > integrations > ESPHome > [devicename] page, and they can be changed from there or via lovelace panels. Whenever you change a value on your HA display panel it is automagically updated on the ESP32, and so you don’t need to store a copy of it.
That works because ESP devices are normally always available.
But there are scenarios where you might need the ESP32 to run when it is not connected to HA. If so, please let us know more about your project so we can give more focussed advice.
Actually this is what happens when you use deep_sleep on the ESP32 … because the ESP32 is physically powered off when it is “asleep”, HA cannot contact it to update variables. And then you find yourself furiously trying to make changes in the brief time when the ESP32 is awake.
In this case (and I guess this is what you actually want to know)…
In HA set up your input helper - you said yours is input_number.test_int.
In ESPHome, setup a sensor (or other component which allows the homeassistant platform). The entity_id: is what links this ESPHome component to the input_helper in HA.
That’s it. When the ESP32 is awake it checks the current value of number_test from HA and synchronises with it. Just use ha_sensor as you normally would.
i have used Global variables for retaining values through a period of deep_sleep.
Looking back at the code you posted in your first post … I don’t see anything wrong with it - which suggests the problem was elsewhere.