fix: Home Assistant: guard value templates against missing properties - #33071
deviantintegral wants to merge 4 commits into
Conversation
c205305 to
47a5435
Compare
|
|
For most entities, the guard never fires. adjustMessageBeforePublish will inject the key with For the ones without a matching mockProperty, the template renders So, the only visible effect is that the Jinja warnings stop. Hopefully! I do think it's likely this could fully replace mockProperties, but that's probably a bigger change. Is that better as a separate PR or bundled in here? |
ce909c0 to
535be60
Compare
If you see the chance, than I would prefer to bundle it here. |
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ChP1SPEr3tYXAVp4S2o9Kr
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ChP1SPEr3tYXAVp4S2o9Kr
535be60 to
69e2a10
Compare
The discovery value templates now check that a property is present before reading it, so there is no longer a reason to pad every published payload with `null`s for properties the device hasn't reported yet. Drop the `mockProperties` mechanism entirely. Payloads only carry what was actually reported, and entities without a value keep their previous state instead of being reset to unknown on every message. The `update` entity, whose payload is built from nested reads, is guarded the same way and now reads `state` with `.get()` so a payload without it does not log a template variable warning either. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QcurGn7eowCt5Uh1Whxnq3
69e2a10 to
ca21778
Compare
|
Done! Let me know if you think we should preserve |
|
great, I migrated the remaining cases, will merge this after the 1 October release such that we get enough test time. |
I'm getting occasional errors when devices report with missing properties in Home Assistant. This PR should fix that!
I'm pushing the tests first which should fail, followed by the fix.
This PR also removes
mockPropertiesbased on the discussion below. Of note is that messages no longer contain properties withnullvalues.Before:
After: