Sending "ON" Command from the home.sitemap definition

Gentlemen,
I didn’t search “deeply” for this on the forum, but I hope this can be a quick answer.
I have the Python script working well on my secondary Pi to “pressgaragedoorbutton”.

I used Rich Koshak’s suggestion for a Garage Door thingamajig in the sitemap like this and it is working well.

home.sitemap:
Frame label=“Doors”
{
Switch item=garagedoor icon=“garagedoorclosed” mappings=[ON=OPEN] visibility=[garagedoor == CLOSED]
Switch item=garagedoor icon=“garagedooropen” mappings=[ON=CLOSE] visibility=[garagedoor == OPEN]
Switch item=garagedoor icon=“garage_detached_selected” mappings=[ON=NULL] visibility=[garagedoor == NULL]

}

Shows like this (Garage door is currently open)

image

The Items file appears like this… one is subscribing to the topic “readgaragecontactstatus” and working as expected. The other is trying to send or publish “pressgaragebutton”. If I publish pressgaragebutton from another client, the garage door opens or closed as expected.

Switch garagedoorbutton “Garage Door” { mqtt=">[openhabianpi:pressgaragebutton:command:default:ON]" }
//
Contact garagedoor “Garage Door” { mqtt="<[openhabianpi:readgaragecontactstatus:state:REGEX((.*?))]"

When I click the CLOSE on the WEB GUI, I see this in the log:
2018-08-13 11:14:16.416 [WARN ] [.classic.internal.servlet.CmdServlet] - Received unknown command ‘ON’ for item ‘garagedoor’

What defines the action on the sitemap when I click “CLOSE” ?
Should this be a rule or is the MQTT setup improperly that publishes pressgaragebutton ?
(I’m not super-good with rules syntax yet) :slight_smile:
Thanks fellers!!

‘garagedoor’ is a Contact type Item. Contact Items don’t accept commands (they are considered to be sensors).

Presenting ‘garagedoor’ on your Sitemap as a Switch type doesn’t change the underlying Item, but it does allow the display of Switch-type buttons. Clicking a button sends a Switch-type command to the Item - which rejects it, as it’sa Contact Item.

1 Like

Cool,
I had that set as Switch… but I kept getting a NULL event for that item.
When I changed to Contact, the NULL went away and the status of OPEN or CLOSED would appear in the WEB GUI… (Basic and iPhone app) and the Event Log
How do I correct that?
There REALLY is no way to click on a button in the GUI and have it send the publishtopic command?

I can imagine sharing a bunch of this stuff with folks attempting to do the same things that I’m doing.
Using a secondary or “thirdary” Pi that is connected to sensors that grabs the required info via a Python script and allowing it to communicate with the 3rd Pi that is running the Broker and OpenHAB2.

I created a cool little sensor (not yet installed… too hot during the day… too lazy at night :slight_smile:) that sticks up into the Electric meter and senses the rotations of the kilowatt wheel. My research has shown that 1 rotation equates to 1 Watt? 1 kilowatt? can’t recall right now :slight_smile:
But, the Python script will count the rotations per second or minute and convert to how much power is being used.
But, I want to get past this garage door thingy first.
I ask again… there is no way to tie a button to what is presented in the WEB GUI or Phone app directly?
(Sorry, too much verbiage for this original topic) :blush:

I don’t follow where you are now. Regardless of what you had before, you cannot have a Contact Item with a clickable button in the UI. If you want a clickable button, you must use a Switch type Item.

Bear in mind a Switch type has states ON and OFF. Sitemaps lines using visibility would need to look for those states, not the OPEN/CLOSED of a Contact type.

Okee Dokee, rossko57…
I’ll try some stuff! :slight_smile:
Thanks, man!!

Should be

Switch item=garagedoorbutton...

You got the sensor and actuator backwards. The item needs to be the actuator, not the sensor. The visibility part is right though. You want to control the visibility based on the states of the sensor Item.