Sitemap - Switch

I’m starting to get somewhere with my Garage Door opener.
I have created everything i.e. Bindings, Things, Channels and Items, all in Paper UI.
My switch to activate the door stays on for 1 second then.resets to off.
In Paper UI > Control the switch works correctly. It is displayed as a slide switch and when I turn it on it returns to off automatically after 1 second. Also my status indicator shows OFF when the door is closed and ON when it is open.
I used Visual Studio Code with openHAB integration to create the item lines in sitemap. In Basic UI when the switch is moved to on the relay bounces but the switch icon doesn’t return to off. To activate the door again I have to move the switch to off then to on again and the status doesn’t change. Why are these working correctly in Paper UI > Control but not in Basic UI?
Here are my two item entries in sitemap;
Switch item=GaragedoorActivate label=“Garage Door Open/Close”
Text item=GaragedoorStatus label=“Garage Door State” valuecolor=[garagestate==“OFF”=“green”,garagestate==“ON”=“red”]

I 've checked the documentation and sitemap examples but can’t work out why it is not working.

We need more details like your item definition and bindings used etc to help.

Main question how are you turning the switch off after 1 second?

I use the Tasmota command pulsetime1 10 entered at the Tasmota console. This turns the switch off after 1 second, no rules needed.
Creation of all bindings, things, channels and items is done in Paper UI. The only script is sitemap.

Do you want your "activate"Item never to indicate ON? Set autoupdate false.
Do you want your “activate” Item to return OFF after a delay? Use expire binding.
Do you want your “activate” Item to return OFF after the garage door state changes? Use a rule.
Do you want only one button in your sitemap, instead of a slide switch? Use mappings= with Switch widget.

1 Like

I would use the mapping command in sitemap and map on only. It’s a one click solution.

You have to also make sure your state topic in tasmota is coming across correct. This way it will send the off back to openHAB. Assuming it will send the off in this configuration.

Another thought ; what does your “activate” Item actually do in your events.log? Are you in fact looking for a sitemap refresh issue?

1 Like

UPDATE.
After further testing I find that the open/close switch works as expected, i.e. it turns on the off after 1 second in Paper UI > Control, Classic UI and openHAB Android App but turning it on in Basic UI activates the door but doesn’t return to off. I have to do that manually.
There is only 1 sitemap so why does it work in in 2 UIs but not in the other?
Just curious now because I’m happy with Classic UI and Android app.
Now to get the text to change with the changing state of the door. It works in Paper UI > Control but not in the any UI defined by sitemap so I guess the problem is in that part of site map.
Here is what I have at present;
Text item=GaragedoorStatus label="Garage Door State " icon=“Garagedoor-100” valuecolor=[garagestate==“ON”=“green”,garagestate==“OFF”=“red”]
In all but Paper UI > Control it just remains a green ON.

TRY putting a %s in your label. Forget if it is uppercase or lower.

On the basic ui did you manually refresh your web browser? It may have updated but the page did not refresh.

It just displays as %s.
I do refresh my browser window every time I make a change.

You must put it between [] like [%s].
Oh and please try to use code fencing, it reads a lot easier for others :wink:

UPDATE.
Forgot the brackets [%s]
Now it works.
All I have to do is workout how to change the ON to OPEN and OFF to CLOSED.
Thanks everyone for your help.
I’m now going to create a document bringing together all that I have learnt so that other noobies can follow to setup Garage Door Automation with no previous knowledge of openHAB.
Now for my next projects.
I have an SMA Solar Inverter and a Home Security Alarm that uses the Smart Life app which is Tuya Compatible and would like to integrate them both.

This is Classic UI when door is open.
image

Use a MAP in your Item [format]

Why don’t you change that slide switch to a single button using mappings= in the sitemap?

Thanks for your suggestions rossko57.
I already have MAP in my item but it doesn’t do anything.
Here is what I have;
String GaragedoorStatus “Garage Door State [MAP(gd.map):%s]” {channel=“mqtt:topic:sonoffsv_1:garagedoor_status”}

gd.map
ON=OPEN
OFF=CLOSED

I will look into mapping to change my slide switch to a button.

The MAP transformation service is an option to be installed.

The documentation seems vague to me on this topic. I’ve tried MAP as above and I’ve tried profile as part of the channel definition but I still get ON/OFF instead of OPEN/CLOSED.

Channel profile will not help you. A Switch type Item may only have useful states ON and OFF, no matter how you manipulate a channel. That’s fine, just go back to a normal default channel profile (which means none at all when defining in xxx.items files).
Doing random stuff without understanding isn’t going to help, no-one suggested a profile for this job.

What a MAP transformation does is look up the actual Item state in a simple lookup table, and present the new value for display in your UI. For display only, the actual Item state remains unchanged.

There’s a few things you need to get right for it to work. MAP works for everyone else, so you know it’s just a mistake or omission.

So you need a xxx.map file. What you have shown us for your gd.map looks like sensible content.
You need to put the file in the right folder. Exactly where depends on your operating system. but typically "something-openabbish"/conf/transform
You’ll know when you are at the right folder because when the openhab install created it, files de.map and en.map were put there.
The file needs to be in UTF-8 format, like all openhab config files. How you arrange that depends on your text editor.

You need to install the MAP transformation service. It’s an optional add-on.
You’ve not confirmed that you have done or checked that.

Then you need to specify your MAP in the Item label text, the [state presentation] part in square brackets. You specify which transformation service to use, in this case MAP, and any parameters it wants, in this case the map lookup file to use. Then you give an actual print formatter, which is invariably %s for “string” when any transformation is used.
The Item definition you gave earlier looks fine, with [MAP(gd.map):%s]

When you use a UI that relies on a sitemap, like BasicUI, note that any label you give in your sitemap widget line will override any label you defined in your Item definition.
To be clear, a sitemap entry like
Switch item=GaragedoorStatus label ="some text [%s]"
will stop your MAP content from being visible.
Either leave out the label (and so get the default label you already defined in your Item)
Or use the sitemap defined label with the [transform] specified as well / instead.

If a transformation fails for whatever reason (no service installed, no successful lookup) it will pass the original state unaltered.

Thanks very much rossko57 for your help. That solved my problem. I answered the different points you made above as I read your reply and of course they are irrelevant now.
Here is the result.
image
image

Coloured text as well now, well done :smiley: