Tasmota Bed Sesor

Thanks for this guide - really does work great. I did the same hardware but with tasmota instead of esphome (only because that’s what I’m familiar with, haven’t used esphome). With a nodemcu esp32 and the recommended fsr.

Quick and easy setup, cheap, and works really reliably. Awesome :slight_smile:

1 Like

Thx a lot. Also want to use tasmota with two fsr’s.

Can you please share your config?
How did you solved the filtering in tasmota like OP did with esp home?

thx a lot

I recently switched it all to esphome, haha. In terms of the actual in/out binary sensor, there is no noticeable difference on my setup. I just wanted to move away from mqtt and into the direct api. Also, I didn’t ever do proper filtering, I just had an analog remap which acted somewhat as a filter, and a small delay time on the in/out binary sensor.

Tasmota just set up generic nodemcu esp32, and set the relevant gpio to ADC input.
This will report raw analog input. You can use it as is, I was converting it down to a 0-100 range which effectively resulting in rate-limiting/filtering.

Sample command that I used:

AdcParam1 6, 700, 2200, 0, 100

1: ADC channel 1
6: tasmota ADC linear range remap
700, 2200: observe the min-max raw ADC when you’re in and out of bed (it should show on the main web UI screen). This sets the min and max, basically 700 will map to 0, 2200 will map to 100.
0, 100: the min/max to remap between

Set rules;
Init var1, activate rule

Rule1 ON SYSTEM#Init DO var1 0 ENDON
Rule1 1

When analog ranged value changes, publish mqtt. If you want it to publish less often, then you could make a separate rule for the publishing, and only publish if the change is greater than a value for example. For my FSR ranged to 0-100 this was stable enough to not have excessive updates (and little to no updates during the day when not in bed), but may be different depending on your setup.

Rule2 On ANALOG#range1!=%var1% do backlog0 var1 %value%; Publish2 stat/master-bedroom/%topic%/rawbedsensor %value% endon
Rule2 1

In home assistant config yaml: (assumes setting up input number as per OP)
MQTT sensor

# Bed sensor
    - name: "Bed Sensor ADC Ranged"
      state_topic: "stat/master-bedroom/esp32Bed/rawbedsensor"
      availability_topic: "tele/master-bedroom/esp32Bed/LWT"
      unique_id: "bedsensor_adc_range"
      payload_available: "Online"
      payload_not_available: "Offline"
      state_class: "measurement"
  - binary_sensor:
    - name: "Master Bed Presence Detected"
      unique_id: "master_bed_presence_detected"
      delay_on: "0:00:05"
      delay_off: "0:00:05"
      state: >
        {{ states('sensor.bed_sensor_adc_ranged')|float < states('input_number.master_bed_trigger_level')|float }}

Dash card needs minor changes to suit (I don’t have them any more)

thx a lot for the infos!

Here is the original thread, just for reference: FSR - the best bed occupancy sensor

Configured it now, but i found an issue in Rule2:

Rule2 On ANALOG#range1!=%var1% do backlog0 var1 %value%; Publish2 stat/master-bedroom/%topic%/rawbedsensor %value% endon

backlog0 should be changed to backlog (without 0):

Rule2 On ANALOG#range1!=%var1% do backlog var1 %value%; Publish2 stat/master-bedroom/%topic%/rawbedsensor %value% endon

This works for me.
Can you please change your post?
So if anyone finds it, they will use the correct rule.


@paul09 thx a lot for the infos. Built the sensor with an ESP32 + tasmota + 2x FSr’s, it’s workinng really good!