diff --git a/docs/user/configuration/infrequent-sensors.md b/docs/user/configuration/infrequent-sensors.md index 124819d..310d4c6 100644 --- a/docs/user/configuration/infrequent-sensors.md +++ b/docs/user/configuration/infrequent-sensors.md @@ -4,7 +4,7 @@ When using an external temperature sensor (like a thermostat or Home Assistant s Ideally the external temperature sensors would provide updates frequently enough to avoid this timeout, but many sensors provide less frequent updates (especially battery powered sensors) or only publish a value when the temperature has changed. -There are multiple workarounds for this challege, but two recommended workarounds are presented below: +There are multiple workarounds for this challege, but some recommended workarounds are presented below: ## Echo Configuration @@ -67,4 +67,52 @@ actions: - data: current_temperature_C: "{{float(states('sensor.env_basement_temperature'))}}" action: esphome.env_basement_hp_report_temperature -``` \ No newline at end of file +``` + +## After an ESP restart + +After an ESP restart (firmware update, restart, power blip) there is no remote temperature to send until the selected +source reports again. A connected MHK2 needs about a minute to reconnect, and a Home Assistant sensor only arrives once +the API reconnects. The [echo](#echo-configuration) can't help here, because a restart clears the last reported +temperature, so units that revert quickly fall back to their internal sensor in the meantime. + +This snippet keeps the source's last temperature in flash, and after a restart re-sends it every 5 seconds until the +source reports again (at most 3 minutes). The example uses "Thermostat" (MHK2) as the source: + +```yaml +globals: + - id: saved_temp + type: float + restore_value: true # kept in flash across restarts and power loss + initial_value: 'NAN' + +sensor: + - platform: mitsubishi_itp + thermostat_temperature: + name: "Thermostat Temperature" + id: tstat_temp + on_value: + - globals.set: + id: saved_temp + value: !lambda return x; + +esphome: + on_boot: + priority: -100 + then: + - while: # until the source reports (max 3 min), re-send the saved temperature + condition: + lambda: return !id(tstat_temp).has_state() && millis() < 180000; + then: + - lambda: id(hp_climate).temperature_source_report("Thermostat", id(saved_temp)); + - delay: 5s +``` + +This assumes your climate component has `id: hp_climate`. For an additional source instead of the MHK2, put the +`on_value` on that sensor, and use its `id` and its name (as shown in the Temperature Source select) in place of +`tstat_temp` and `"Thermostat"`. + +:::note +After a long power outage the saved temperature may be out of date. It's only used until the source reports again, and +never for more than 3 minutes. +::: diff --git a/docs/user/configuration/temp-sources.md b/docs/user/configuration/temp-sources.md index b479cc0..6837ba7 100644 --- a/docs/user/configuration/temp-sources.md +++ b/docs/user/configuration/temp-sources.md @@ -11,7 +11,8 @@ If an update from the sensor is not received after 7 min, the component will swi internal temperature sensor. Ensure any sensors report at least every 7 minutes. The heat pump itself will revert back to the internal sensor after approximately 10 minutes without an update, and this -component enforces that check. +component enforces that check. Some units revert much sooner (around a minute), which can cause unexpected timeouts even during an ESP32 reboot/update; see +[Dealing with Infrequent Sensor Updates](infrequent-sensors.md). ::: ```yml