Bon, et bien ça ne fonctionne pas.
Il a donc fallu que je crée un sensor template pour remonter un capteur affichable sous HA.
La mémorisation après remise sous tension ne fonctionne pas non plus, ce qui était le but.
J’ai testé avec un restore_value à yes ou à no, sans effet.
La validation s’effectue bien sur appui d’un bouton. La valeur passe bien à 2.8. Mais après coupure et remise sous tension, la variable global revient à 0
La carte est une ESP32 NodeMCU de chez AZdelivery
Qu’est-ce que je rate ?
esp32:
board: nodemcu-32s
framework:
type: arduino
# -----
# -----
globals:
- id: global_offset_pH
type: float
restore_value: no # Test yes idem
sensor:
- platform: template
name: "Template offset pH"
update_interval: 1s
lambda: return id(global_offset_pH);
binary_sensor:
- platform: homeassistant
entity_id: input_boolean.bouton_validation_valeur
id: bit_validation
on_press:
then:
- globals.set:
id: global_offset_pH
value: '2.8'
EDIT : Je dois re-tester. Je viens de lire ceci. Il est possible que je n’ai pas attendu suffisamment longtemps que ma variable global soit mémorisée en flash, avant de couper la tension de l’ESP.
Adjusting flash writes
Example configuration entry preferences: flash_write_interval: 1min
- flash_write_interval (Optional, Time): Customize the frequency in which data is flushed to the flash. This setting helps to prevent rapid changes to a component from being quickly written to the flash and wearing it out. Defaults to
1min
.
As all devices have a limited number of flash write cycles, this setting helps to reduce the number of flash writes due to quickly changing components. In the past, when components such as light
, switch
, fan
and globals
were changed, the state was immediately committed to flash. The result of this was that the last state of these components would always restore to its last state on power loss, however, this has the cost of potentially quickly damaging the flash if these components are quickly changed.
A safety feature has thus been implemented to mitigate issues resulting from the limited number of flash write cycles, the state is first stored in memory before being flushed to flash after the flash_write_interval
has passed. This results in fewer flash writes, preserving the flash health.
This behavior can be disabled by setting flash_write_interval
to 0s
to immediately commit the state to flash, however, be aware that this may lead to increased flash wearing and a shortened device lifespan!
For ESP8266, restore_from_flash
must also be set to true
for states to be written to flash.