Configuration of a smart fire sensor

i’m trying to make a smart fire sensor to send notifications if any fire detected . i built up my sensor using esp8266 module and burned the software image to it .
then i checked it using mqtt broker and it seemed to be working well as shown .


after that i tried to bind it with openhab but it doesn’t give me any response .
i think the problem is with my configuration files .
those are :
things file :

items file :

sitemap file :
sitemap
rules file :
rules
help please … where is the problem !!

What is the topic that FIRE DETECTED! is published to? Your configuration suggests it should be stat/mofiresensor/POWER, but your MQTT.fx would suggest it is something else…

Your Thing definition is also slightly off. It should look something like

Thing topic mofiresensor "mofiresensor" {

...
}
1 Like

@mohamed

Better put the text from the Things, Items and Rules between three backquotes before text and three backquoyes after the text.

It save you time by now making a screen print.

this one three times `

1 Like

You probably want to keep an eye out for channel names being case sensitive, string / String. Really that’s a poor choice of name, it’ll only confuse things later.

1 Like

Absolutely, from MQTT.fx it is apparent that your topic for the “FIRE DETECTED!” string is just mofiresensor, so for that topic to register it should be

stateTopic="mofiresensor"

not sure why you didn’t set the topic similar to the LWT topic in your ESP8266, e.g.

tele/mofiresensor/state

or something like that.

With “#” you subsribed to all topics in MQTT.fx, the top line at the bottom bit, which you circled - top circle line going through it, is the topic, the second line shows the subsription, 3rd line obviously date and time, what is in the black area below is the payload.

Then in your items it need to be lower case “string”, as @rossko57 points out

channel="mqtt:…:string"

Not typing it all, can’t even copy and paste from your pictures :stuck_out_tongue_winking_eye:

1 Like

i corrected the faults and it worked .


the remaining thing is how to obtain a notification !

Notification, where what? In the openHAB app?

Yes , notification at the openhab app when fire is detected … !
as i mentioned this is the rule i created for that purpose …
rules
but it doesn’t work …!
should i define a thing or channel for that , or what should i do ?

You would want to use something like this:

Item mofiresensor changed

Generally for this type of on/off, true/false sensor, it is better off to use a Switch rather than a String. I also happen to build a smoke sensor with ESP as well, using the MQ-2 sensor. Mine is a bit more complicated as it has to handle the ramping up until the sensor is stable, as well as the occasional high value spike (but no smoke). Here’s my MQTT file:

      Type number : smokeValue "Bedroom3 Smoke"                                                              
        [stateTopic="esp/bedroom3/smoke/value"]                                 
      Type switch : smokeState "Bedroom3 Smoke State"                           
        [stateTopic="esp/bedroom3/smoke/state", on="1", off="0"] 

And here’s the item mapping:

Number SF_Bedroom3_Smoke "Smoke Value [%d]"                                     
  { channel="mqtt:topic:bedroom3:smokeValue",                                   
    wifi="true", autoReport="true" }                                            
                                                                                
Switch SF_Bedroom3_SmokeState "Smoke Detected [%s]"                             
  (gGasSensorState)                                                             
  { channel="mqtt:topic:bedroom3:smokeState",                                   
    wifi="true", autoReport="true" }

The rule would go like this:

@rule("Dispatch gas sensor state change event.")                                
@when("Member of gGasSensorState changed")                                      
def onGasSensorStateChanged(event):   
...

Hope this helps.

1 Like

I’m grateful