Doorsensor state does not work


#1

Hi, when i try to use my door sensor, the state in basic UI is just a small line like this https://gyazo.com/7165c6cfb44732ba7d0df6099c0048f2 Not open or closed. Mqttfx does show the state correctly.


#2

Please, share with us your .sitemap and .items codes


#4

Woah, please format the code next time by highlighting it and pressing the code symbol above.
Items:

//Demo items
Switch DEMOSW “Demo Switch”

List item
//Security items
Switch SecuritySystem “Alarm Anlegg”
Contact DoorSensor1 “Dør Status [%s]” { mqtt="<[broker:SmartHjem/Sikkerhet/DoorSensor1:state:default]" }

Sitemap:

sitemap home label=“Smart Hjem”
{
Frame label=“Demo”
{
Switch item=DEMOSW
}
Frame label=“Info”
{
Switch item=DEMOSW
}
Frame label=“Sikkerhet”
{
Switch item=SecuritySystem
Text item=DoorSensor1
}
Frame label=“Rom Eskil”
{
Switch item=DEMOSW
}
Frame label=“Inngang”
{
Switch item=DEMOSW
}
Frame label=“Stue”
{
Switch item=DEMOSW
}
Frame label=“Bod”
{
Switch item=DEMOSW
}
Frame label=“Utendørs”
{
Switch item=DEMOSW
}
}

Esp8266 code:

/* WIFI Settings /
// Name of wifi network
const char ssid = “0000”;

// Password to wifi network
const char* password = “000000”;

/* Web Updater Settings /
// Host Name of Device
const char host = “DoorSensor1”;

// Path to access firmware update page (Not Neccessary to change)
const char* update_path = “/firmware”;

// Username to access the web update page
const char* update_username = “admin”;

// Password to access the web update page
const char* update_password = “admin”;

/* MQTT Settings /
// Topic which listens for commands
char outTopic = “SmartHjem/Sikkerhet/DoorSensor1”;

//MQTT Server IP Address
const char* server = “Raspberry Pi adress”;

//Unique device ID
const char* mqttDeviceID = “SmartHjemDevice1”;

#5

ok, so i got the state to work properly. Now i only need help to get the notifications to work

//This is the rules file

//Side Door Sensor Is Open
rule "Dør Status Sensor"
when
   Item DoorSensor1 received update OPEN
then
       if(SecuritySystem.state == ON)
       {
           sendBroadcastNotification("DØR HAR BLITT ÅPNET!!!")
       }
end

#6

Your rule seems correct, so it should work. Just try opening and closing the door to see the status, the notification should appear on your smartphone .


#7

Thx it worked lol. Probably just a bug


#8

how did you make it work? I am having the same issue (the status is not displayed in the UI while working fine in MQTTfx)and can’t find a way out.


#9

You should try to check /var/log/openhab2/opehab.log


#11

Have you figured it out yet?


#12

How did you get it to work, I too have the same issue. I have made a seperate posting with pictures. Can you check it out and see where the error is.

Ill post here if that is more convenient for you


#13

I had the same issue. I realized i didn’t setup MQTT properly when I SSHed into my PI.


#14

Hi there. How do you solve the state problems? I’m facing the same error. I’ve reinstalled mqtt binding, and follow everything in this forum, but nothing change. Help me please