I like the simplicity of this idea. Yet so effective!
Nice use case for that sensor, too.
Still working as expected?
My bed sensor has probably been broken by the kids jumping in our bed.
And since this method is below the bed it seems to be kids safe.
Do you have to recalibrate it often? Do you get a new value when you take it off and put it back in? I mean does it “set” differently enough to need a recalibration?
That’s what the threshold (in this case > 30) is for.
You will need to find your own personal point once and then you are good because the ruler is fixed mounted.
I understand that, but how often does it need to be calibrated.
Is there a drift noticed in the value?
Yes, it does work still. No need to recalibrate yet.
Probably the battery change will be the first moment for removing and reattaching it.
Unfortunately my integration only offers the 3 axes as attribute. Therefore I need to create a template sensor for the axes separately. Anyone an idea how to achieve that?
Zigbee2MQTT creates three separate sensors - X, Y, Z. You can probably make a template sensor to extract just one value from the combined sensor but you’ll have to ask somebody else as I suck at templates.
I’m using the orientation attributes to monitor whether someone is tampering with my open bedroom window. If you like, play around with the parameters.
{%- set base = state_attr('binary_sensor.vibrationssensor', 'orientation') -%}
{%- set x = base[0] |int(0) -%}
{%- set y = base[1] |int(0) -%}
{%- set z = base[2] |int(0) -%}
{{ x }}
{{ y }}
{{ z }}
#### Examples:
{{ z not in [87, 88, 89, 90] }}
{{ z > 88 }}
Pushing this a bit further:
How to use that vibration sensor (which is a sensor.bed) as a device_tracker.bed ?
Aiming at removing my shitty GPS based device tracker and instead use the WiFi based plus vibration sensor ones (vibration sensor during night when smartphone is in flight mode).
With ios, wifi tracking is super unreliable. GPS works great, probably like 99% reliable. Is it different on Android or whatever OS you are using?
With all my iOS devices, WiFi tracking is super reliable, using the router integration which has a 180 seconds delay for „has left the WiFi“.
GPS mostly not working (discovering especially entering home zone way too late or not at all, probably 6 to 7 out of 10 times it is not working which is very frustrating).
And some users in my home can’t use GPS (which by the way drains the battery reaaaaaally fast as HA app needs constant background sync), so WiFi plus „overnight presence detection“ sounds like a really interesting option.
Anyone?
Only device tracker entities can be mapped to a person, right? So how to achieve that…?!?
Finally found a way (not tested by myself but according to others‘ experience working quite well) to create a device_tracker entity to assign the bed sensor to a person:
Just tried. It doesn’t do anything and I used a longer ruler to ‘exaggerate’ the movement. Not sure if my mattress is too new :(. I tried changing the sensitivity of the sensor to “high” though it didn’t do anything. None of the many outputs of the sensor device change at all when I lie down.
@ncd I just implemented this in the past week. and I was in the same boat to begin with. I ended up putting the very end of the ruler between the wooden lath and the mattress (Can’t remember exactly how much of the ruler maybe 10 or 15 mm.) giving the ruler a more dramatic angle towards the floor. I also used a strip of double sided tape at the edge to cause friction so it wouldn’t slide out, when getting in and out of bed, with the mattress moving. This gave me a difference of approx 9 degrees on the z axis. and has been working perfect so far. Maybe that might work for you?
thanks to @Stooovie for the idea, the pressure sensor mats were so unreliable.
I bought one on a whim thinking it would be the most gimmicky bit of tech I introduced to Home assistant, but ended up creating a bunch of automations around it, and adding the sensors to conditions of existing automations. So I’m hoping this solution continues to be a solid replacement.
Would you be comfortable sharing a pic? What is the length of your ruler? I had the same thoughts as you that the longer the ruler , the greater the force (bigger lever ) so the movement would be more dramatic. I have a 12 inch ruler and the sensor is attached at the very end and I only slide in the tip of the other side but it just doesn’t budge. I don’t have a super fancy mattress but it is quite good and I have a feeling it’s just dampening the entire effect. I’m also only 5’7"(1.71m) so that probably isn’t helping either. Otherwise the bed frame has slats and looks very similar to the OP’s post.
I’m thinking of using the Awara FP2 I just got and carve out a space in the area where the bed is and any time it detects someone there it will assume the person is " in bed". I haven’t had a chance to play with it yet just got it…
@ncd I think I was a bit over confident with the post above the angle kept changing, most likely due to the ruler being so close to the edge, I tired it again with less of an angle towards the floor and instead turning the ruler to the side. It’s giving me a consistent difference in degrees now.
Hope that helps but as you said maybe it’s not suitable for your mattress type.
Looks like a cool solution to the problem. I wanted to go the pressure sensor and esp32 route but for me that has a problem: I want the sensor to be able to detect who is sleeping on which side. Sometimes when I go to bed late my wife sometimes sleeps on my side. I want to detect the weight to recognize if it is me or my wife on each side of the bed as I want to run different sleep automations than her.
AFAIK the pressure sensors just detect weight or no weight. I think this solution could work as I am significantly heavier the angle would be different between us. Has anyone tested this?
Also one caveat I see is that we have a box spring bed with a 25 cm thick mattress plus a topper. It does not have slats. Has anyone made it work on a box spring?
Hey! I am trying your method out currently, but I am using a Samsung contact sensor. I’m just not sure what you mean by “tune the zero point”. The y axis when the ruler is flat on my desk currently shows 43… so what would be your suggestion in terms of tuning your template? Thanks heaps! @Stooovie