I have a global variable that is being restored from flash and then being passed into a custom sensor’s constructor. The problem is that the global value is not being restored until after the sensor is initialized, so it ends up passing 0 into the constructor. Looking at the Boot Priority documentation, it sounds like initial states should be restored before initializing sensors. Any ideas to make this happen?
globals:
- id: saved_gallons_count
type: int
restore_value: yes
sensor:
- platform: custom
lambda: |-
auto wf = new WaterFlowSensor(id(saved_gallons_count));
App.register_component(wf);
return {wf->flow_rate_gpm_sensor, wf->gallons_used_sensor};