my new home has a mailbox on a hinge. the idea is I can open the front door of the mailbox and pull upward and the box will tilt to face me on the porch and let me reach in and pull out my mail. it is on ground level and the letter carrier delivers mail from the driveway height, not porch height. so if the letter carrier delivers mail, the mailbox door opens, no tilt occurs, the box closes whereas if I check the mail, the mailbox door opens, the box tilts up, the box tilts back down, the door closes.
I’m using a shelly BTHome window/door sensor. this sensor has. tilt sensor in it, but it only shows 0 when closed. when opened, that’s the reference point and any tilt past that is what it compares against to get its rotation value.
So my idea is triggering only the door sensor means mail was added, but triggering the door AND tilt meant I took mail out and should clear the you-have-mail state.
I’m struggling with this template. I cannot figure out how variables are supposed to work here.
Have you considered using a Wait for Trigger with a timeout instead of whatever you are doing with that Repeat? If the wait times out without triggering for rotation, then you assume it was a delivery, if the rotation trigger fires you assume its you collecting. Or you could have no timeout and just use rotation and door closing as separate triggers for the Wait… if you think that makes more sense.
You've also got a bit of nonsense in there... but none of this is actually necessary for anything
- if:
- condition: state
entity_id: wasTilted
state: true
then:
The variable wasTilted is not an entity ID… and what you have supplied isn’t even the value of that variable, it’s just the string “wasTilted”. You can test a variables truthiness using a Template condition. Since you are assigning either true or false as the value, all you need is the variable name inside expression delimiters: