Move IMAP Email Content body to an attribute#11096
Conversation
|
|
||
| if self.sender_allowed(email_message): | ||
| message_body = EmailContentSensor.get_msg_text(email_message) | ||
| message_body = EmailContentSensor.get_msg_subject(email_message) |
There was a problem hiding this comment.
The variable name is no longer accurate.
|
Thanks for catching that. I've fixed the variable name. Technically this is a breaking change since the default state value is now the email subject instead of the email body, but only if value_template is not specified in the sensor config. What's the proper way to flag this as a breaking change? |
|
@balloob I think this sensor should not be a sensor and just fire events. At the moment it's a wired stuff. |
|
@pvizeli you are right. We should convert this to just fire events. But for now, this PR is fine. |
|
Is this issue because of the schema design of the states table? With more and more things adding attributes for display type of purposes, do you see the need for either a properties object that isn't logged, or maybe configuration on the recorder that allows you to ignore or filter out attributes before it is written to the database? |
|
No, if the sensor was meant to show the last item, it doesn't do that. Instead it cycles through 1 each time so people can listen for state changes of each email. This means they just want events when email arrives, making automation go faster too because you're not waiting for older email to be cycled through the state. |
Description:
This change to IMAP Email Content sensor makes the state the email subject and moves the body to an attribute. This is to work around the new 255 character limit for states.
Related issue (if applicable): fixes #10512
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#4199
Example entry for
configuration.yaml(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passNew dependencies have been added to theREQUIREMENTSvariable (example).New dependencies are only imported inside functions that use them (example).New dependencies have been added torequirements_all.txtby runningscript/gen_requirements_all.py.New files were added to.coveragerc.