Bed Presence for ESPHome by Elevated Sensors

Just in case you weren’t aware, there’s a Time of Day helper natively built into HA which is designed for this very purpose (using additional features in yaml mode).

Thanks for the heads up. I think I may have looked into that briefly before I went with my own implementation. But that was one of the first things I did in HA, so I don’t remember now. :smile:

That one seems more based around actual times (in the HH:MM sense; and/or sun rise/set +/- offsets) rather than what I am referring to, which perhaps more accurately should be called “parts of day”.

For example, if it is “Evening” and no Occupancy detected in Main Room for x minutes → Change Time of Day to “Bedtime”.

Or, with a reliable bed sensor (as we discuss in this thread) → Bedtime (as opposed to some HH:MM).

1 Like

I’ve been using the generic time of day binary sensors to set fixed times like Morning, Lunchtime etc. However, my smart home is all about context and your method seems to apply a degree of context to “parts of the day”. I like that as I tend to have to set quite wide time windows, particularly for bedtime and get up time, as conditions of things happening based on triggers from the bed presence sensors.

I’ll have a look at that and see what I can improve on. Thanks.

1 Like

Looking back now on my own “time of day” implementation, I seem to have polluted it with occupancy a little (see “daytime home” and “daytime away”). Maybe there was some reason for that at the time, but now looking back that seems to me like a code smell. As I said, that was one of the first things I did in HA and back then I probably didn’t know any better.

Also by now I have developed quite robust groupings of sensors for Motion and Presence, which combine into Occupancy, by room and for the whole house, and all of that should probably remain separated, conceptually.

So I probably should revisit that as I try to keep my automation logic as clean and maintainable as possible.

It appears that what the authors of the Wizard Book were trying to tell me is finally sinking in. :smile:

1 Like

Since the device isn’t rebooting, I think we can rule out a power issue. The Wi-Fi signal strength also looks solid, which is great.

A couple of quick questions:

  • Do you have any other ESPHome devices in your setup?
  • If so, do they exhibit similar disconnects?

Here are a few things you can try to improve connection stability:

  • Reserve a static IP for the device in your router settings (avoid hardcoding it in ESPHome).
  • If you have a mesh Wi-Fi setup, and your router supports it, try pinning the device to a specific access point so it’s not roaming between nodes. That can cause dropped connections.

It’s also worth noting that the ESPHome team is aware of a low-level issue in some ESP32 chipsets that causes random API disconnects. They’re actively investigating, and a longer-term fix may come from either the ESPHome team or Espressif in a future firmware update. We’ll continue to monitor that situation and push out updates as we’re able.

If none of these options help, the best workaround is to make your automations resilient to brief “unavailable” states. For example, instead of triggering on Detected, you can trigger only when the state changes from Clear to Detected. This avoids false positives from transitions like Detected → Unavailable → Detected.

3 Likes

I have a 10" latex mattress (3 layers, firmest on bottom) resting on a platform bed. The “lift tops” are 3/4" plywood.

Will this combo work?


Yes, that should work fine as long as you add on the mounting kit.

@FantasyMaster85 Hi I was wondering if you tell us what lights you went with for your under bed runway lights?

it looks pretty evenly distributed, so I’m assuming an LED strip of some kind?

hue or govee or something else ?

anyway, looks great, thanks for the demo!

Hello from down under. :wave: Got my delivery today and immediately ripped the bed apart to install it. Just curious as to how far up/down the bed is everyone installing theirs?

I put them on a slat below the mattress where aprox. the pelvis is. Works well.

1 Like

The official instructions say:

Select a bed slat in the torso region, where most of your weight will be applied to the bed (think about where you sit or lay in bed). If possible, select a bed slat that does not rock side to side.

I installed mine under my butt (pelvis) too. Works well for me.

1 Like

Fantastic, I’ve just ordered the mounting kit and the sensor, I’m so excited and looking forward to it. My previous solution with the Zigbee water detector from Aqara and the pressure bands only cost me nerves and was anything but stable. I now hope to have found a reliable and permanent solution.

Not too near the bottom of the bed because of the dog. :roll_eyes:

Ended up installing it nearer to the top to cover the torso region; works better if you have the dual sensor for bigger bed, especially if you end up sleeping diagonally, at least one sensor would be activated.

1 Like

Ordered 2x of these. Absolutely love them. Great work.

Matt

1 Like

Mine arrived today. Having such a terrible memory I was excited because I’d forgotten I ordered one! :man_facepalming:

1 Like

How did this work for you? I have a similar frame and want to use this device