Bed Occupancy Sensor

no rule on the esp, it just fires values every 2 seconds. to not spam my home assistant history, i divide the value down and round it, so that it doesn’t change the sensor when idle.

  - platform: mqtt
    state_topic: "kinderzimmer/weight/Weight"
    name: "bett gewicht"
    value_template: "{{ (value | float /1000) | round(0) }}"
    qos: 0
    unit_of_measurement: "kg"
    #force_update: true
    availability_topic: "kinderzimmer/status/LWT"
    payload_available: "Connected"
    payload_not_available: "Connection Lost"

so even if the esp constantly fires values between 1500 and 2500 the sensor remains idle/stale and stays at 2 kg.

Ok, thanks. That’s what I am doing right now. I guess I should stop worring about the poor ESP8266 sending unused messages most of the time :grin:

As the weigth difference between my wife and myself seems not big enough to have a reliable sensor to messure who’s sleeping, I just tried to connect a second HX711 + 2 load cells to my NodeMCU to measure both sides of the bed independent of each other. But it seems that unfortunatly two instances of the HX711 sensor are not support (at the moment) by ESPEasy. Should have tested it before soldering another one, but I guess the dog bed will get a sensor now :smirk:

Hi @jordan.schulze did u have any errors with the code? I have uploaded it but cannot connect to Wi-Fi throws some random error.

Hi @diplix how did you configure your mqtt in espeasy? There is no option of homeassistant mqtt? So how can I set it up?

I am getting negative values I have followed your method and configuration.

My mqtt topics do not give any result either. Please help.

Above all that my espeasy setup is from letscontrolit.com. is that fine? I followed your guide.

Many thanks

see

do you mind sharing your mqtt settings please? a screenshot maybe?

I looked into that topic but didnt find much help.

thanks.

thank you @diplix

now what are your mqtt topics in home assistant that you subscribe to for getting the weight values?

scroll up a little or/and see

is that what you mean? bett/weight/Weight?

but what is the following?

/%sysname%/%tskname%/%valname%

where can i find mine?

UPDATE: ok found it !

@diplix can you please help me on calibration?

how can I achieve it? using your formula? thanks

i don’t know what you mean. if you get values compare them and automate accordingly; compare the value you get for an empty bed with the value you get if the bed is occupied.

Can you explain the logic behind your formula?

The values keep changing so there isn’t a constant value

in case your refering to this formula in esp-easy: ((%value%+135750)*-1)/20

this formula is supposed to set the value sent by espeasy to approx. zero. before i mounted the sensor into the bed, i measured a 1 kg pack of flour, noted the change and came up with this formula. if i remember correctly espeasy reported a value of around -135750 without any weight applied and a value around −155749 with a kilo flour on the sensor. with the formula i get (around) 0 for no weight and (around) 1000 with a kilo applied.

(((−135750)+135750)×−1)/20 → ~ 0
(((−155749)+135750)×−1)/20 → ~ 1000

the values reported by espeasy change a lot, so i round the value in homeassistant to full kilograms, so that only changes greater than 1000 change the homeassistant sensor value.

value_template: "{{ (value | float /1000) | round(0) }}"
1 Like

Was your value of -135750 fixed or did it go up and down? Because mine is going up and down like anything

like i said, it changes all the time but not more than ±1000 in a state of rest. without looking it up, i guess it’s more or less around a range of 300. what’s your range of change?

@diplix Well the first 3 digits don’t change just the last 3 digits do. So they vary from -294380 to -294424

ok I have sorted it many thanks for your help.

Sorry for missing so many comments, I forgot that I posted this project here :slight_smile:

For anyone asking for source code or wiring diagrams, mine are in the GitHub project linked in the first post.

@bachoo786 for calibration I simply set the UART to print raw values, zeroed out the reading, lay down on the bed, and checked the reading. The ratio between your mass and the raw value is the calibration factor. This is not the most precise way of doing things, but I am more interested in the Boolean occupied/not occupied so it did not have to be perfect.