Push button

Hi,

i want make in my OH push button, which will do:

On start is OFF.

If i push it, it call program prog with specific parameters and change to ON.

Now is ON, i push it, it call program prog with other parameters and change to OFF.

It’s similarly like a clasic switch but i don’t want classic swich but only one push button which will updating own status.

Is that possible?

1 Like

Hi,
in sitemap you just doing something like this:

Switch item=Nachtmodus label="Normalbetrieb" mappings=[ON="Nachtbetrieb"] visibility=[Nachtmodus==OFF]
Switch item=Nachtmodus label="Nachtmodus" mappings=[OFF="Normalbetrieb"] visibility=[Nachtmodus==ON]

Only one off both is visible. First is visible if the state is OFF. Pushing the On-Button labeled “Nachbetrieb” switching it to ON. “OFF” disappear and “ON” get visible.

1 Like

I try it, but it doesn’t work.

Sitemaps:

Switch item=Nachtmodus label=“Normalbetrieb” mappings=[ON=“Nachtbetrieb”] visibility=[Nachtmodus==OFF]
Switch item=Nachtmodus label=“Nachtmodus” mappings=[OFF=“Normalbetrieb”] visibility=[Nachtmodus==ON]

Items:

Switch Nachtmodus { binding=“xxx”, autoupdate=“false”, exec=“>[ON:/home/pi/openHAB/program turn pin1 ON] >[OFF:/home/pi/openHAB/program turn pin1 OFF]”}

Hi,
the sitemap should work the way i postet. But i can’t proof if this item configuration is correct. Maybe the ON-OFF is used the wrong way. Did you try an “fake” switch-item without binding configuration. Just “Switch Nachtmodus” to be sure that the “push button ui” is working properly. After this you can fix the item itself if there is something wrong in syntax.

Thing item should look like this.

Switch Nachtmodus { exec=“>[ON:/home/pi/openHAB/program turn pin1 ON] >[OFF:/home/pi/openHAB/program turn pin1 OFF]” }

But i don’t now anything about this part /program turn pin1 ON. Are you sure thats right?

1 Like

Hi,

I check it, your advice was right, problem was that switch was at start openHab uninicialized.
I get rule and now it works.
Thanx for your advices.

1 Like