Present Sensor using ultrasonic sensor

Hi everyone,

Ive been working my items and rules on how to display if my garage is occupied or empty but I could not figure out.

Here is my sitemap:
Text item=garage_car_present

ITEMS:
Contact garage_car_present “Garage Car Present [MAP(car.map):%s]”

RULES:
rule "Car Present"
when
Item garage_ultrasonic_dist received update
then
if (garage_ultrasonic_dist.state <24)
{
sendCommand(garage_car_present, ON)
}
if (garage_ultrasonic_dist.state >30)
{
sendCommand(garage_car_present, OFF)
}
end

MAP:
ON=OCCUPIED
OFF=EMPTY

Where did I wrong? Please help me:frowning:

Use the “Switch” item type, not contact.

Switch garage_car_presence “Garage Car Presence [MAP(car.map):%s]”

you missed “ultrasonic” -> garage_ultrasonic_dist

Maybe you should use the method instead of the Action:

garage_car_presence.sendCommand(ON)

What are the logs telling you?
Did you receive the right values?
Is your item garage_ultrasonic_dist a number item?
Maybe you should use:

if (Garage_ultrasonic_dist.state as DecimalType < 24)

Andreas

You can use contact if you replace ON/OFF with OPEN/CLOSED in rule und map.

Thanks for your immediate response. I tried all but still no luck.
I can see the update in the ultrasonic sensor though.
I have PIR sensor and it shows the status if there are any movements. It does because the output produces either 1 or 0 while the ultrasonic sensor show variable outputs and in decimal number.
Are there any other way to show the status if the garage is empty or occupied using ultrasonic
sensor?

SOLVED. I fix it by adding a logical condition to my Arduino.

Cheers!