-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Improve MQTT template docs on handling null values #38485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for home-assistant-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
📝 WalkthroughWalkthroughThe pull request updates documentation examples and descriptions. In the templating configuration file, an additional JSON key ( Changes
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
source/_integrations/sensor.mqtt.markdown (1)
204-205
: Improve Description of Null/None Handling in State TopicThe updated description now correctly explains that:
- An empty string (
''
) is ignored,- A
'None'
value sets the sensor to anunknown
state, and- When using a
value_template
for JSON payloads, anull
value renders as'None'
.One nitpick: the hyperlink syntax has double parentheses. Consider changing
- a null value in the JSON [will be rendered as]((/docs/configuration/templating/#using-value-templates-with-mqtt)) 'None' + a null value in the JSON [will be rendered as](/docs/configuration/templating/#using-value-templates-with-mqtt) 'None'to improve consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
source/_docs/configuration/templating.markdown
(1 hunks)source/_integrations/sensor.mqtt.markdown
(1 hunks)
🔇 Additional comments (1)
source/_docs/configuration/templating.markdown (1)
1639-1645
: Clarify JSON Null Handling in Templating ExampleThe added JSON payload now includes
"humidity": null
, and the accompanying note clearly explains that when processed by avalue_template
, thenull
value is rendered asNone
. This update improves clarity and helps users understand the template’s behavior with null values.
Hey there @emontnemery, @bdraco, mind taking a look at this feedback as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @jbouwh 👍
Proposed change
Improve MQTT template docs on handling
null
/None
values. For MQTT sensor this was not correctly documented.The current docs say
null
could be used to set the MQTT sensors state tounknown
. That is only when a value in a JSON payload is rendered. In factNone
is expected, either from a rendering template or as payload.Type of change
current
branch).current
branch).next
branch).next
branch).Additional information
Checklist
current
branch.next
branch.Summary by CodeRabbit