Door Sensor state not working


#1

Alright, now that I’ve got your attention.

If you’re thinking about running away stop. Please.

While you’re here can you help me?

I’ve copied the code from the forums into their designated spots in openhabian yet despite this the state on the sensor isn’t updating.

//This is the items file

//Demo items
Switch DEMOSW “Demo Switch”

//Security items
Switch SecuritySystem “Security System”
Contact MKDoorSensor1 “Side Door [%s]” { mqtt="<[broker:MK-SmartHouse/security/MK-DoorSensor1:state:default]" }


sitemap home label=“MK-SmartHouse”
{
Frame label=“Demo”
{
Switch item=DEMOSW
}
Frame label=“Information”
{
Switch item=DEMOSW
}
Frame label=“Security”
{
Switch item=SecuritySystem
Text item=MKDoorSensor1
}
Frame label=“MK-Room”
{
Switch item=DEMOSW
}
Frame label=“JK-Room”
{
Switch item=DEMOSW
}
Frame label=“Master Bedroom”
{
Switch item=DEMOSW
}
Frame label=“Living Room”
{
Switch item=DEMOSW
}
Frame label=“Garage”
{
Switch item=DEMOSW
}
Frame label=“Outside”
{
Switch item=DEMOSW
}
}


//This is the rules file

//Side Door Sensor Is Open
rule “Side Door Sensor”
when
Item MKDoorSensor1 received update OPEN
then
if(SecuritySystem.state == ON)
{
sendBroadcastNotification(“SECURITY SYSTEM: SIDE DOOR OPEN”)
}
end

All I see is an open door and a small rectangle instead of “closed” or “open”

MQTTFX shows open and closed though

Summary

This text will be hidden


#2

Can you show a picture


#3

There are the pictures. Just today, my rules file disappeared. I have no idea what happened.

Thanks in advance


#4

My sitemap file


#5

My rules file

Rules


#6

In the openhab logs or rest api, can you see the state?
In addition to that, do you get notifications?


#7

Also, can I see a picture of the basic ui problem itself?


#8

I cannot see the state in the openhab logs, but I do see errors in regards to SecuritySystem.


#9

Logs


#10

Basic UI with no security state


#11

Switch change but no state change


#12
  1. Try defining your securitysystem item in a new file ( this fixes that error)
  2. show the logs when you open/close the door

#13

You can see the state in mqttfx right?


#14

Try making the mkdoorsensor item a string (just for debugging purposes)


#15

I can see the state in MQTT


#17

Do you mean that in the sitemaps file I should make the Text item MKDoorSensor1 a string?

Or that in the items file I should make MKDoorSensor1 a string?


#18

Should I delete the original items file?

If so how do I got about deleting it?


#19

When I flip the switch in BASICUI I see these state changes in the logs. However, I still don’t see state changes in BASICUI.

The door sensor in real life doesn’t change anything in the logs or BASICUI when it opens/closes. It will however change the state in MQTT when it opens/closes .


#20

This means that there is something wrong with the openhab MQTT.
Don’t delete your items file.
Try reinstalling the MQTT binding.


#21

Did you get it working? You posted elsewhere that it worked now