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
mqtt:
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"
template:
- 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)