Hello all.
I want my PC to shut down as soon as my backup is complete.
The only feedback I get from the backup is a mail. I have successfully created an imap_email_content sensor that works and gives the correct status (success/warning/failed).
But now I have a few questions about the implementation:
I can query the status of the sensor in the automation. But if I get a mail with status “successful” every day, the value of the sensor never changes and I can’t set it as a trigger.
I also can’t set a time trigger that queries a condition, because a) I don’t know when the backup is exactly finished and b) the sensor could read the mail from the previous day, because maybe none came today.
So I need a trigger that reads and deletes the mail as soon as a new mail arrives.
Can I realize this somehow or do I understand the sensor basically wrong?
#--------------------------------------------------------------------------------------------------
# Set the state or other attributes for the entity specified in the Automation Action
#--------------------------------------------------------------------------------------------------
inputEntity = data.get('entity_id')
inputStateObject = hass.states.get(inputEntity)
inputState = inputStateObject.state
inputAttributesObject = inputStateObject.attributes.copy()
newState = data.get('state')
if newState is not None:
inputState = newState
newIcon = data.get('icon')
if newIcon is not None:
inputAttributesObject['icon'] = newIcon
hass.states.set(inputEntity, inputState, inputAttributesObject)
Thank you for your detailed answer.
I will have a look at it. But is there really no easier way to check mails? It would be enough if HA would read the mail and then delete it. Or if HA marks the mail as read and he only processes unread mails.