Need some Openhab settings for a magnetic contact

I tried all the ways with capital letters and small letter, numbers but it doesn’t want to go if i define the item “Contact” the result is unavailable.
If i leave “Number” instead of “Contact” and in the map i use 1=open 2=close it works but as i said it doesn’t move the icon . By the way, the frontdoor icon don’t want to appear even i have it in the images folder.
The shield was just as an example that it works with item type “Number” and after checking the image folder i saw that the green one is labeled shield-1.png and the red one is shield-0.png so this item work well.

Why i cant see the front door icon even i have it in my image folder. Also the door icon doesn’t work too? The icon for the front door is frontdoor-open.png and frontdoor-close.png.

Thanks for the answer.

The door icons will only work with Contact items and will not work with Number items.

I bet the problem is the MAP. We also need to map it to the data being read in from MQTT, not just in the label.

Replace the “default” after “state” in your mqtt binding config with “MAP(door.map)”

Contact	Node01Door	"Usa acces [MAP(door.map):%s]"	<frontdoor>	(GF_Living)		{ mqtt="<[mymosquitto:home/door:state:MAP(door.map)]" }

I really don’t know what’s happening with this simple thing (this suppose to be really simple) but for me it doesn’t want to work as it is normal to work!
I tried your eg and is not working …
There’s something wrong with the door and frontdoor icons, they just don’t want to appear in the web! if i change “door” or “frontdoor” with “contact” the icon appear but is grey so this means is just an icon not a contact item type.
In the door.map i tried again all the version like:

open=OPEN and closed=CLOSED or 0=OPEN and 1=CLOSED or OPEN=OPEN and CLOSED=CLOSED

nothing…

The other eg for the weather is like impossible for me for the next 2 years to make it work if i face so many troubles with this simple thing .

NEWS:
If now i use this item:

Contact	Node01Door	"Usa acces [MAP(door.map):%s]"	<frontdoor>	(GF_Living)		{ mqtt="<[mymosquitto:home/door:state:MAP(door.map)]" }

with map:

0=CLOSED and 1=OPEN

the frond door icon appear and more over it works BUT i dont see the text in the right side of the web with OPEN or CLOSE status.
if i change something in the map like 0=open or 0=Open it’s not going to work anymore.
How do i make the OPEN / CLOSE status to appear on the web?
Thanks again.

Excellent news! Almost there. Hopefully you are learning how all of these OH configurations work and how they work together now. The first project is always the hardest. And since you moved to MQTT you have a good foundation for expanding you HA system with more Arduino based sensors and actuators going forward.

Hopefully you are reading the wiki as well as these postings and the examples to learn what all of these things mean and how they are interacting with each other. If so the Weather binding will be no sweat. The weather binding is MUCH easier to work with so once you get this MQTT stuff working start to play with the Weather binding. After I got my first couple of switches to work in OH I spent a month or so experimenting with the Weather and Astro bindings. These two are great for learning because they don’t require a bunch of external stuff to work along with it and they let you start to program some cool capabilities like turning on the lights when the weather says its cloudy or turning on a light 90 minutes before sundown.

I think I know what is going on. We already mapped the 0, and 1 to OPEN / CLOSED in the MQTT binding (stuff in { }) and the resultant value is used for the Contact’s value. Thus, when the UI goes to display it the value is already set to OPEN or CLOSED so the MAP in your label text doesn’t work as it only has values for 0 and 1.

You can either eliminate this MAP in the label (e.g. “Usa acces [%s]”) which should put OPEN or CLOSED (note the all caps) on your sitemap. I’d try this first to make sure this is indeed the problem.

If you would rather it be all lower case or just the first letter capitalized, or have the Romanian? (Google translate’s guess) for open and closed printed, add “OPEN=deschis”, and “CLOSED=închis” (or whatever you want to convert the OPEN / CLOSED to on your UI) and leave the item definition unchanged from what is currently working with the icons. Note that this sort of mapping may prove useful as you start to experiment with the Weather binding if you want to translate the values from English in your display.

Do not edit or remove the 0=CLOSED and 1=OPEN. You need to add these as new lines.

There is a tiny chance this won’t work as expected. If it doesn’t create a new map file with the OPEN= and CLOSED= and use that map in the label text.

Thanks Rich, you were right, all i had to do was to remove the MAP in the label.
You guessed right, I’m from Romania and because it’s working with OPEN/CLOSE i prefer to leave it like this instead of DESCHIS/INCHIS :slight_smile:
However there is something wrong. I’ll try to make a short description: if i leave the configuration like this is working well, i mean i can see in real time when the contact is closed that Openhab changes its status from OPEN to CLOSE but when developing application with multiple items, this contact still works but not in real time. When i close the contact nothing appears on the web, the door is still open. If i move to another page or out of the app and get back in, i see the contact CLOSE but not in real time! Why is that?
I would like to ask you if i need multiple MAP’s like door1.map, door2.mao,…for multiple contacts or i can use this one i have right now?
You right, I am reading on wiki, I’am testing some of the examples but there are a lot of things i don’t understand. You saw the contact e.g. I simply could not make it work from the first shot.
You said you have some switches working on Openhab, may i ask you if you can share your configuration?
For the moment the 4 sensors i have connected on the Arduino work well but you remember on the beginning of this topic I was asking for some OH settings because i had one switch (contact) working following the tutorial form MySensors (different solution) and now because i followed another tutorial form another site everything is different.
My old wish is to have a small home automation system for a few switches which suppose to have to ways communication for lights: physical button and OH button for one light and to see any changes of the status in real time, A few sensors like temp, humidity, electric (SCT-013-000), water, gas using some sensors for the Rasberry and Arduino.
The bad thing is that every time i try to modify or to develop any Arduino sketches i face a lot of troubles, errors that i can’t clean and so all the time i’m changing the solution following a different tutorial or topic which suppose to use different sensors or different solution as for example now when i changed the communication from the serial to Mqtt and from MySensors to Home automation for geeks.
Hopefully with this solution i’ll be able to add the elements i want in my small home system.

Thanks again for this detailed explanation and

This is a behavior that I and others have seen. I think the UI doesn’t poll the server often enough to always see all the changes all the time. The problem seems worse on Android and iOS clients than on the web UI. I’ve not had problems with Contacts before. It is usually with switches. See this thread for more discussion on the problem.

You can use the same MAP for all your doors.

I can but don’t know how terribly useful they will be regarding the configuration. As I hope you are realizing, everyone has different requirements and approaches to HA. My approach may not be suitable for what you want to achieve or be compatible with the examples you are finding and copying from online.

I have three z-wave switches and two HTTP binding based switches (which I’m probably going to move to a MQTT configuration for consistency at some point). I’m using a z-wave USB dongle as the controller so I have the “zwave:port” property in openhab.cgf set to “/dev/ttyUSB0” which is where the USB dongle resides. The HTTP switches are calling the REST API of WebIOPi on a Raspberry Pi wired to a couple of relays.

Items:

Group:Switch:OR(OFF,ON) gLights "All Lights"    <light>
Group gWeatherLights "Lights controlled by weather conditions and twilight" <light>
Group gOffTimerLights "Off Timer Lights" <light>
Group gSunsetTimerLights "Sunset On Lights" <light>

Switch  S_L_Front           "Front Room Lamp"           <light> (gLights, gOffTimerLights, gWeatherLights)     {zwave="3:command=switch_binary"}
Switch  S_L_Family          "Family Room Lamp"          <light> (gLights, gOffTimerLights, gWeatherLights)     {zwave="4:command=switch_binary"}
Switch  S_L_Porch       "Front Porch"               <light> (gLights, gOffTimerLights, gSunsetTimerLights) {zwave="6:command=switch_binary"}
Switch  S_L_All         "All Lights"                <light>

Switch  T_D_Garage1             "Garage Door 1"                 <garagedoor>
Switch  T_D_Garage2     "Garage Door 2"                 <garagedoor>

Note: I have two additional zwave switches that get toggled when one of my Raspberry Pi controllers is detected as being offline to too long. I’ve found the Raspberry Pis are not very stable and drop offline far too often. I’m not going to show these here though as they don’t add anything regarding Switches.

Rules:
The Garage Door switches are implemented in rules rather than on the Item definition primarily because I have a bunch of book keeping and such that I want to do in addition to just triggering the garage door. The rules call a lambda (reusable function) that constructs a URL to get and sends a notification if the door is opened and no one is home or if the Network Health binding is saying that the Raspberry Pi is not online.

import org.openhab.core.library.types.*
import org.openahb.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*
import org.eclipse.xtext.xbase.lib.*

val Functions$Function1 openGarage = [ String garageNum |

        logInfo("Garage Controller", "The garage door " + garageNum + " has been triggered")

    var url = "http://192.168.1.201:8000/GPIO/"
    switch garageNum {
        case "1" : url = url + "17"
        case "2" : url = url + "22"
        default : url = null
    }

    if (url == null) {
                sendNotification("rlkoshak@gmail.com", "Received cmd to trigger unknown garage door: " + garageNum)
        logError("Garage Controller", "Received cmd to trigger unknown garage door: " + garageNum)
        }
        else {
                url = url + "/sequence/500,01"
            logDebug("Garage Controller", "The URL is " + url)

                sendHttpPostRequest(url)
                if (gPresent.state != ON) {
                        sendNotification("rlkoshak@gmail.com", "Garage door " + garageNum + " has been triggered.")
                }
                if (gGarageNet.state != ON) {
                        sendNotification("rlkoshak@gmail.com", "The garage controller may be offline, trigger may have failed: WEBIOPi = " +
                                N_C_GarageWebIOPi.state + " Raspi = " + N_C_GarageRaspi.state + " Repeater = " + N_C_GarageRepeater.state)
                }
    }
    true
]

rule "Garage Door Opener 1"
when
        Item T_D_Garage1 received command
then
        openGarage.apply("1")
end

rule "Trigger Garage Door Opener 2"
when
        Item T_D_Garage2 received command
then
        openGarage.apply("2")
end

The lights rules are quite a bit more complicated. If you put the light Switches on the sitemap as is they will work as is, no need for rules. However my HA automation philosophy is that it should automatically do what it should and if you have to use a user interface it is a HA failure.

The lights have four cases. Some go on when the Weather Binding Condition ID says it is cloudy. Some turn on 90 minutes before sundown (twilight), some that turn on at sundown, and some those that turn off at 11 pm. Most lights are members of multiple of these groups. If during the day a light is manually turned on, the Weather rule is disabled for that light.

import org.openhab.core.types.*
import org.openhab.core.library.items.*
import org.eclipse.xtext.xbase.lib.*
import java.util.Map
import java.util.Set


//-------------------------
// Global Variables
//-------------------------
val String TIMER = "TIMER"
val String WEATHER = "WEATHER"
val String MANUAL = "MANUAL"
val Map<SwitchItem, Boolean> overridden = newHashMap
var boolean day = true
var String whoCalled = ""

// Yahoo cloudy weather condition IDs
val Set<String> cloudyIds = newImmutableSet("0",  "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",
                                                "9", "10", "11", "12", "13", "14", "15", "16", "17",
                                                "18", "19", "20", "26", "28", "35", "41", "43", "45",
                                                "46", "30", "38")

val Functions$Function4 applySwitch = [ State state,
                                            boolean override,
                                            String whoCalled,
                                            SwitchItem light |
        if(state != light.state) {
                if(!override) {
                        logInfo("Lights", whoCalled + " turning " + light.name + " " + state.toString)
                        sendCommand(light, state.toString)
                }
                else {
                        logInfo("Lights", whoCalled + " " + light.name + " is overridden")
                }
        }
]

//-----------------------------------------------------------------------------
rule "Lights System Startup"
when
        System started
then
        whoCalled = MANUAL
        gLights?.members.forEach[light | overridden.put(light as SwitchItem, false) ]
end

//-----------------------------------------------------------------------------
// TODO Figure out how to deal with it being called three times for each update
rule "Any light in gLight triggered"
when
        Item gLights received update
then
        Thread::sleep(250) // give lastUpdate time to be populated
        val mostRecent = gLights?.members.sortBy[lastUpdate].last as SwitchItem
        logDebug("Lights", "Most recent is " + mostRecent.name)
        if(whoCalled == MANUAL) {
                logInfo("Lights", "Overriding " + mostRecent.name)
                overridden.put(mostRecent, true)
        }
end

//-----------------------------------------------------------------------------
// The Any gLight triggered will be called for each of items in gLights, causing
// them to become overridden
rule "All Lights"
when
        Item S_L_All received command
then
    gLights?.members.forEach(light | sendCommand(light, S_L_All.state.toString))
end

//-----------------------------------------------------------------------------
rule "Lights Twilight"
when
        Item Twilight_Event received update
then
    logInfo("Lights", "Timer turning Twlight lights.")
        whoCalled = TIMER
        day = false // deactivate the weather rule

        gWeatherLights?.members.forEach[light |
                overridden.put(light as SwitchItem, false)
                applySwitch.apply(ON, false, TIMER, light)
        ]
end

//-----------------------------------------------------------------------------
rule "Lights Sunset"
when
        Item Sunset_Event received update
then
        logInfo("Lights", "Timer turning on Sunset lights.")
        whoCalled = TIMER

        gSunsetTimerLights?.members.forEach[light |
                overridden.put(light as SwitchItem, false)
                applySwitch.apply(ON, false, TIMER, light)
        ]
end

//-----------------------------------------------------------------------------
rule "Lights Bedtime"
when
        Time cron "0 0 23 * * ? *"
then
    logInfo("Lights", "Timer turning off bedtime lights.")
        whoCalled = TIMER

        gOffTimerLights?.members.forEach[light |
                overridden.put(light as SwitchItem, false)
                applySwitch.apply(OFF, false, TIMER, light)
        ]
end

//-----------------------------------------------------------------------------
rule "Lights Sunrise"
when
        Item Sunrise_Event received command ON
then
        logInfo("Lights", "Good morning, activating Weather Lights rule")
        day = true
        whoCalled = MANUAL
        gLights?.members.forEach[light |
                logDebug("Lights", "Populating overridden map with " + light.name)
                overridden.put(light as SwitchItem, false)
        ]
end

//-----------------------------------------------------------------------------
rule "Weather Lights On"
when
//      Time cron "0 */10 * * * ?" or
        Item Condition_Id changed
then

        if(day) {
                logDebug("Lights", "Checking the weather conditions")
                var State state = OFF
        if(cloudyIds.contains(Condition_Id.state)) state = ON

                whoCalled = WEATHER
                val i = gWeatherLights?.members.iterator
                while(i.hasNext) {
                        val light = i.next
                        logInfo("Lights", "Processing " + light.name)
                        if(overridden.get(light) == null) overridden.put(light as SwitchItem, false)
                        applySwitch.apply(state, overridden.get(light).booleanValue, WEATHER, light)
                }
                Thread::sleep(500)
                whoCalled = MANUAL
        }
end

Sitemap:
The sitemap configures the garage door switches as mere buttons and I have it configured where it uses a different icon based on whether the door sensor says it is open or closed.

The lights have two switches on the sitemap. One switch that will toggle all of the lights. The other is a Group that when clicked will show all the lights which can be switched individually.

  Frame label="Controls"{
        Switch item=T_D_Garage1 label="Garage Door 1" icon="garagedoor-closed" mappings=[ON=Open] visibility=[N_D_GarageDoor1!="OPEN"]
        Switch item=T_D_Garage1 label="Garage Door 1" icon="garagedoor-open" mappings=[ON=Close] visibility=[N_D_GarageDoor1=="OPEN"]
        Switch item=T_D_Garage2 label="Garage Door 2" icon="garagedoor-closed" mappings=[ON=Open] visibility=[N_D_GarageDoor2!="OPEN"]
        Switch item=T_D_Garage2 label="Garage Door 2" icon="garagedoor-open" mappings=[ON=Close] visibility=[N_D_GarageDoor2=="OPEN"]
    Text item=gGarageNet label="Garage Door Control Is Not Online!" visibility=[gGarageNet!="ON"]
Switch item-S_C_Garage label="Reset Garage Controller, turn off then on" visibility=[gGarageNet!="ON"]
    Switch item=S_L_All icon="light"
    Group item=gLights label="Individual Lights" icon="light"
  }

In openHAB a Contact is not the same thing as a Switch. A Contact is a sensor that shows whether something is OPEN or CLOSED. A Switch is an Item that can be turned ON or OFF. How it is shown in the user interface and how you use them in your rules and how you set them up as an Item are all different. You need to know and understand these sorts of things to be successful with openHAB which is why I am constantly pointing you to the wiki.

I highly recommend using a commercial solution for this. Z-wave, Insteon, and Hue all seem to be pretty popular among posters here on the forum. If you want to roll your own, you will need to code something on whatever is controlling your relay that can received commands from openHAB (e.g. MQTT message, HTTP REST API call which is what I have right now in the garage), etc.

Again, this is why I keep suggesting you spend the time to learn these technologies. You will spend far less time in the long run and experience far less frustration if you get to a point where you can understand what is happening, what the errors are and what they mean, and how to fix them. Otherwise you will be running from one example to the next and failing to get it to work or breaking what already works. I know you have spent a lot of time on this and are learning a lot but still a lot of your questions show a lack of understanding of some very basic things you should know to be successful.

This is what I was afraid. Honestly this is too much for my understanding at this moment.
I really don’t want to use now other technologies like zwave or philips, I just want to use my present installation but with small modification like installing some relays in my electrical panel and from there some wires through my existing cable trays or directly in the false ceiling. Moreover I have already some spare cables installed and I want to use them.
You were right, I can’t use your eg right now but maybe if you move from http to mqtt I may be using some of your configuration.

About the door.Map I added another 2 window contacts but they are not coded in the Arduino yet and when I open the existing one all 3 contacts display open or close, is this normal?
About controlling some of the switch I have to find answers from other sources but I would like to ask another thing:
I have an electrical strike and I want to make some kind of OH button that will display in text and color like in blue when is on or close and with red color when is off or open. The button should look like the the one for the dinner, evening or movie scene, only that this will indicate my electrical strike state and will control it.
One more question:
I made 1 switch and one dimmer for the same switch and normally when you dimm the light from off to on let’s say 50% the switch should indicate that it’s on but in my case the switch doesn’t do anything even if I dimm the light to 100%.
All eg are copied from github demo.
Many thanks for your time.

I will suggest that reviewing and understanding my example and how you would convert it to MQTT would be a first step towards growing your understanding of openHAB. I really believe that without that basic understanding proceeding to grow your system will be an exercise in frustration.

This is not normal. Are all of your Contacts subscribing to the same MQTT topic?

Please review the Sitemaps wiki page and the demo.sitemap in the demo.sitemap. Pay special attention to the mappings (controls the text of the button), and valuecolor attributes on the sitemap.

I don’t have enough information to help with this one. Remember, you need to post your items, rules, and sitemap or else we are just guessing what could be wrong or how to help.

Man is damn hard to try to learn a new language without a teacher or any other help. Could you imagine how hard is to learn Chinese language and pronunciation without hearing it once?
This is Openhab for me now :smile:

After long searches and readings on the git page i got this item:

Switch FrontDoor "Front door yale state"	<key>

and this sitemap:

Switch item=FrontDoor mappings=[OFF="LOCKED"]

Now as i said i want when pressing the button to change from LOCKED (blue) to UNLOCKED (red), don’t know how!
If i make the mappings like this:

Switch item=FrontDoor mappings=[ON="UNLOCKED", OFF="LOCKED"]

i get two buttons and i don’t want that.
There will be another ask: how to make it stay red / unlocked until the strike will lock by its self . The lock is NC so i would like to keep the red button until the 5 seconds pass, the strike will be locked and the button become blue / locked.
How difficult can be to make this happen?

PS: i managed to add some new contacts on my system and i would like to make a group called contacts who will display on the main page how many of them are open. I know, i have to read on wiki git but can you please tell me where? i couldn’t find this yet.

Thank you! Good bless :blush:

i think you have to deal with .map files, have you already try/read about
them?

there you set the translation “between words and numbers”, depending on
what the Contact/Sensor is sending…

for the Group i remember that in the Demo configuration there was something
about Windows or Doors open/closed, so maybe it helps you out


Edit: i see you already deal with map files, sorry for that suggestion.
It would be nice if you post your config files to better understand/see where are the problems and learn from them too.
Have a nice day

good luck!

Max

I don’t know if there is a straight forward way to do this. What I’ve done in my sitemap is use the “visibility” attribute on the sitemap to hide one version and show the other and then swap between them when the state changes. I should note that this doesn’t work super well on the mobile clients which don’t seem to update very frequently.

Sitemap:

Switch item=FrontDoor mappings=[ON="UNLOCKED"] visibility=[FrontDoor=="ON"]
Switch item=FrontDoor mappings=[OFF="LOCKED"] visibility=[FrontDoor!="ON"]

I’m not sure I completely understand what you are asking. I think what you are asking is to wait five seconds before updating the sitemap when the state changes from OFF to ON.

The only way to do that is to create a proxy item for FrontDoor and then use a rule to keep it in sync with the actual sensor/switch and use a timer.

Items:

Switch FrontDoor "Front door yale state" <key>
Switch FrontDoorProxy "Front door yale state" <key>

Rules:

rule "Update FrontDoorProxy"
when
    Item FrontDoor changed
then
    if(FrontDoor.state == ON) {
        createTimer(now.plusSeconds(5), [| FrontDoorProxy.sendCommand(ON)])
    } else {
        FrontDoorProxy.sendCommand(OFF)
    }
end

Sitemap:

Switch item=FrontDoorProxy mappings=[ON="UNLOCKED"] visibility=[FrontDoor=="ON"]
Switch item=FrontDoorProxy mappings=[OFF="LOCKED"] visibility=[FrontDoor!="ON"]

You need to create a Number item and create a rule to update that item whenever the group gets updated.

Items:

Group Contacts
Contact ... (Contacts) ...

Number numberContactsOpen

Rules:

rule "Update numberContactsOpen"
when
    Item Contacts received update
then
    val numOpened = Contacts.members.filter(contact | contact.state == OPEN).size
    numberContactsOpen.postUpdate(numOpened)
end

Sitemap:

Text item=numberContactsOpen

A lot of the things you are asking are starting to get more advanced. This is good. It means you are growing in your knowledge of openHAB. Keep it up.

Rich

Thanks for the answer Rich, maybe i didnt explain well … I tried your example and its not displaying anything.
I have 3 contacts items like this:

Contact	Node01Door	"Usa acces [%s]"	<frontdoor>	(All, Contacts)
Contact	Node01Geam1	"Fereastra dormitor 1 [%s]"	<contact>	(Contacts)
Contact	Node01Geam2	"Fereastra dormitor 2 [%s]"	<contact>	(Contacts)

and a group in the sitemap:

Group item=Contacts label="Status Ferestre" icon="contact"

What i want to do is to see on the right part of this tab, the number of the opened contacts.
I followed your example and its not working. Could you please be more specific?

About the button blue /red here i tried your eg too and its not changing the color on the web. What i wanted to say was that ill use an Arduino to trigger an relay and than the yale through a 12 volts power source. The red color / unlocked should stay red until the yale / relay will not receive power from the Arduino digital pin so in case i’ll not manage to do this ill choose your eg but it should change its color and text. Right now i couldn’t see this action on the eg you gave me. Where i’m Wrong?

PS: Why you have posted the sitemap in two different ways?

Are there errors in the log? I just typed this in so I don’t know if there are typos. You have to check the log to see if there are errors complaining about errors parsing the Item files or executing a rule. If there is a problem with the rule you will see something along the lines of “Error executing rule …” Things never just not show up without some error being written to the log.

Did you update the names of Items in the rule to correspond to what your actual items are named? Have you installed Designer and are you editing the rules and items there? Designer will tell you if there are errors in a lot of cases before you run.

You have to create another Item to store the count and put that on your Sitemap. If you put the Group on your sitemap there is no way to put the count. If you want the Item that stores the count to act like a Group on the sitemap you have to use the Frames as described in the wiki for Sitemaps.

Items:

Group      Contacts
Contact	Node01Door	"Usa acces [%s]"	<frontdoor>	(All, Contacts)
Contact	Node01Geam1	"Fereastra dormitor 1 [%s]"	<contact>	(Contacts)
Contact	Node01Geam2	"Fereastra dormitor 2 [%s]"	<contact>	(Contacts)
Number  ContactsCount "Contacts [%s]" <contact>

Rules:

rule "Update ContactsCount"
when
    Item Contacts received update
then
    val numOpened = Contacts.members.filter(contact | contact.state == OPEN).size
    ContactsCount.postUpdate(numOpened)
end

Sitemap:

Text item=ContactsCount {
    Frame {
        Text item=Node01Door
        Text item=Note01Geam1
        Text item=Node01Geam2
    }
}

The site may not update fast enough. If you refresh the page do the changes show up? If not look in the log for errors. If so I’m afraid the UI isn’t going to work the way you want it to. I have a similar problem with some of my sitemap items.

I don’t understand the question. You had two different problems which required two different ways to display it in the sitemap. If you are asking why I used Switch for one and Text for the other see the Sitemap wiki, in particular the “Element ‘Sitemap’” section.

Now we are talking :slight_smile:
Thanks! it seems that the problem was that instead of group i should make frame as you said and to put the items in the sitemap! now its working and its displaying the no of the open contacts. I’m still facing the same refresh problem as i said somewhere above, if i open a contact i cant see in the frame the no. changing but if i go inside the frame its refreshing and i can see each contact in real time (1 sec delay). If i go back into the frame, the no. of open contacts is the right one …
I can loose this error by rebooting the Rasberry and restarting everything all over again. Than, after reboot everything seems to work fine and i can see in the frame that the no. is changing depending on the contacts state.
There is still something which is not working well and this is the icon of the contacts in the frame is not active. It doesn’t matter if any contacts are open or closed, the icon is grey, its not changing its form. Can i do something to make it show open contact if any of the contacts is open? if all closed the icon should be closed.

About the button, i dont know how to explain but lets say that if the button is pressed this means that for lets say for 5 sec the button should be red and to display in text inside of it unlocked. After these 5 sec the button should come tho its first state this being blue / locked. Right now using the button on the web, and having this items:

Switch FrontDoor "Yala Usa Acces" <key>
Switch FrontDoorProxy "Yala Usa Acces" <key>

and this sitemap:

Switch item=FrontDoorProxy mappings=[ON="UNLOCKED"] visibility=[FrontDoor=="ON"]
Switch item=FrontDoorProxy mappings=[OFF="LOCKED"] visibility=[FrontDoor!="ON"]

with the rule you posted i see on the RPi terminal that the “FrontDoorProxy received command OFF”, thats all. no color changed or other message on the terminal.

Today i learned a new thing with your help, to create frames as groups and i will definitely apply this for the switches, thanks man.

All the best!

Yes, I see this same problem with my sitemap. It is worse on the mobile devices than on the web page but it occurs there too. I have no solution for this problem. This is just the way it is. I’ve not tried your rebooting trick but if that is what it takes to make it work I’ll just live with it as is.

Yes but not easily. You can use the visibility attribute and apply a different icon depending on whether Contacts is ON or OFF but this will have the same refresh problem you identify above. It also makes your sitemap start to get ugly as you have to reproduce a lot of things more than once.

Item:

Group:Switch:OR(OFF,ON) Contacts // This makes your group also behave like a Switch

Sitemap:

Text item=ContactsCount icon="contact-open" visibility=[Contacts.state=="ON"]{
    Frame {
        Text item=Node01Door
        Text item=Note01Geam1
        Text item=Node01Geam2
    }
}
Text item=ContactsCount icon="contact-closed" visibility=[Contacts.state=!"ON"]{
    Frame {
        Text item=Node01Door
        Text item=Note01Geam1
        Text item=Node01Geam2
    }
}

This is almost certainly the same problem that is keeping the count of your open contacts from updating on the user interface. It is doing the work in the background but the user interface is not updating. There really isn’t much I can suggest for this. It is not something that openHAB was apparently designed to handle.

Note your typo: it needs to be frontdoor-closed.png. You were missing the “d”.

You can also use say <myicon> in items file, then say for a switch (which has states “ON” and OFF"), you would need to place files myicon.png, myicon-on.png and myicon-off.png in the images folder. Also works for Dimmer items (place files XXX-10.png, XXX-20.png etc.) or, like you already found out, for enumeration/integer number items like the shield icon example.

@rlkoshak Rich your second example doesn’t do anything. If i replace the first eg with the second one (group item) no open or close icons appear, i cant see in the sitemap the group or the counter. Maybe the items needs to be modified? I tried also to combine the two eg. but still nothing seems to work.

@mstormi Markus i saw the mistake and i replaced the “t” with “d”. I have already the contact icons in the image folder and the contact icons in the items too, please see 4 comments above but i didn’t understand how exactly to make this to work in the group page (main page) and to have also the counter displaying the right no. of the open contacts.

Thanks!

@mstormi https://community.openhab.org/users/mstormi Markus i saw
the mistake and i replaced the “t” with “d”. I have already the
contact icons in the image folder and the contact icons in the items
too, please see 4 comments above but i didn’t understand how exactly
to make this to work in the group page (main page) and to have also
the counter displaying the right no. of the open contacts.

Not replace but add. You wrote “frontdoor-close.png”, but it has to be
“frontdoor-closed.png”.
I use the following in items file (and no overriding definition in
sitemap
):

Group:Contact:OR(OPEN, CLOSED)Bewegungsmelder   "Bewegungsmelder
[%d]"                                  <present> (Status)

There’s files “present-open.png” and “present-closed.png” in images folder.
UI shows (on right hand side) the number of ‘CLOSED’ items in group
‘Bewegungsmelder’. Technically, it does not count the number of ‘CLOSED’
items,
but the ‘OR’ is being computed at runtime and is a simple math operation
using “1” for “CLOSED” and “0” for “OPEN”.
UI also shows (on left hand side) the icon. If the number of closed
items (the result of the math operation) is 0, then it shows the
(black&white) “present-closed.png” icon.
If >1, it shows the (colorful) “present-open.png” image.
Note: if it’s a contact, you have to use open/closed in items file and
ALSO FOR THE FILENAMES. Whenever it’s a switch, you need to use On/Off,
and whenever it’s a dimmer, I believe
it won’t work because you can’t ‘OR’ integer numbers (well,
theoretically it could display something, I didn’t try. But it does not
make sense because a single dimmer at say 50% would count as 50 items).

Hm… I think we’re talking about two different things :grimacing:
I was talking about Rich eg. here above: “Text item=Note01Geam1” instead of “Text item=Node01Geam1”
Right now my items in the web start with a open or close window icon depending on the contact state. In the image folder i have these types of contact which looks like a window: contact.png which is grey and means that something is not right (not connected), contact-open.png which looks like an open window, contact-closed.png which looks like an closed window and the last one contact-ajar.png which looks like a window open on the vertical axe.
The icon in the group (main page) should be the contact-open.png if one of the contacts is open and contact-closed.png if all the contacts are closed. On the right side of the hand (screen) or group tab i should see how many of the contacts are open depending on their real state and when pressing on the group tab (going inside the group) to see all the items open or closed.
My front door icon at this moment display the right position of the contact so it works! why are you saying about this “frontdoor-close.png”? i don’t understand.

You say that for the contacts state instead of this:

Group:Switch:OR(OFF,ON) Contacts // This makes your group also behave like a Switch

I shoud use your example:

Group:Contact:OR(OPEN, CLOSED)Bewegungsmelder "Bewegungsmelder [%d]" (Status)

Well i did this (of course modified to my config) and using @Rich sitemap but nothing changed since my last post, its not working.

I thought you had used “frontdoor-close.png” as a filename, whereas it needed to be “frontdoor-closed.png” to work. That was the missing “d” I wanted to point you at, but you misunderstood and thought I was referring to another typo. Note the filename part behind “-” MUST literally match the name of the state.
Second misunderstanding, I was actually referring to an icon really showing a frontdoor icon, not just the generic ‘contact’ icon used to represent the status of a frontdoor. (which is what you did, I believe).

Oh dear, lots of misunderstandings today … but I see my line was incomplete, that’s why.
(well in fact it was not incomplete, but I would have needed to put it in quotes for the important part to show up - my mistake, sorry). I just corrected my previous post. Try that again, i.e. add <frontdoor>. That will make the GUI use frontdoor-closed.png and frontdoor-open.png icons (and frontdoor.png in case the item is uninitialized). And remember: no … item=frontdoor … in sitemaps file. That would override the definition in items file.
If you want to define the icon file to use in sitemaps, you would need to add icon=frontdoor to your frontdoor line in sitemap instead.