Read input switch status from GPIO

I am having a terrible time reading an input switch on my raspberry pi in the GUI. I wrote a python script and was able to see the status change there.

Items file

Group All
Group gGroundFloor (All)

Group GF_Living “Living Room” (gGroundFloor)

//Temp Sensors 1

//Temp Sensor 128-000007647f9
Number DS18B20_temperature_28000007647f9e “Water temperature [%.1f °F]” (GF_Living) { exec="<[/home/pi/temp.py 28-000007647f9e:60000:REGEX((.*?))]" }

//Switches

Switch RaspiLED{ gpio=“pin:26” }

//Water Sensors
Contact Window_GF_Frontdoor “Frontdoor [MAP(en.map):%s]” (GF_Corridor, Windows) }

Sitemap

sitemap home label=“Main Menu”
{
Frame label=“MQTT Test” {
Text item=DS18B20_temperature_28000007647f9e
Text item=Switch1

}	
Switch item=RaspiLED	

** Text item=LowThreshold**

}

I am able to see “LowThreshold” on the GUI, but not any status. Do I need to do anything with the .map file?

Ultimately I want this to be used for a water sensor to say “water detected” or “Dry”, and this will be used to send an alarm to an email.

I am very new to this but have gotten my relay drive working, and 1-wire temp sensor, but this switch status is stumping me!

Thank you!

Hi John,
Maybe this thread helps you:

Cheers
Björn

In the future please wrap your code in

```
// some code
```

This will preserve the formatting and make it tons easier to read.

There is no “LowThreshold” Item defined in what you posted above.

Without seeing how that Item is defined I can’t even begin to guess what is wrong or what you are expecting to see.

That being said, here is how I would approach your use case.

I’d define a Contact Item bound to the the water sensor. OPEN would indicate water is present and CLOSED would indicated water is absent.

Contact Water_Detection "Water Detection [(MAP(water.map):%s]"

water.map would contain

OPEN=Water Detected
CLOSED=Dry
```

The sitemap would contain:

    Text item="Water_Detection"

Your rule would be:

```java
rule "Water detected"
when
    Item Water_Detection changed to CLOSED
then
    // send alert
end
```

I have a question.
How you read iformations from Temp Sensor 128-000007647f9?
What code in /home/pi/temp.py?

I have a PaspberryPi, temp sensor and openHab. I want to get info from sensor and display on openhab. and don`t work.
Help me.
Thanks.

You will probably have better luck asking the manufacturer or a forum more specific to that sensor. I’ve never even heard of that sensor and wouldn’t begin to know how to read the data off of it and I’ doubt there are many if any others on this forum who can help.

The problem with temperature sensors and the like is they implement a protocol for communicating their value to the Pi. It isn’t as simple as On/Off like a button or reed switch would be.

This is temp sensor DS18B20. In raspbian os, they named 28000007647f9e (or 2800000*)
I am interested in how read themperature in Raspbery and display in openHab?
What code in Python file /home/pi/temp.py?

This is an openHAB forum. Not a DIY electronics forum. Not a Raspberry Pi forum. The number of users on this forum who could begin to help with this is very small. Once you have some Python script reading the values we can help.

You need to find a generic Raspberry Pi forum, check for a tutorial on AdaFruit or some similar website, and reach out to a wider and more appropriate audience who will be able to help.

ok thanks