Hello there,
I got a question; i 'd like to place an Icon of an open/closed door.
my sitemap file:
Frame label=“Beveiliging”{
Switch item=VoorDeur label=“Voordeur”
Switch item=BijkeukenGarage label=“Bijkeuken > Garagedeur”
}
my items file:
Switch VoorDeur “frontdoor [%s]” {mqtt="<[mosquitto:/beveiliging/voordeur:state:*:default],<[mosquitto:/beveiliging/voordeur:command:state:OPEN:1],<[mosquitto:/beveiliging/voordeur:command:state:CLOSED:0]"}
Switch BijkeukenGarage “door [%s]” {mqtt="<[mosquitto:/beveiliging/bijkeukengarage:state:OPEN],<[mosquitto:/beveiliging/bijkeukengarage:state:CLOSED]"}
I have an arduino subscriped on the topic and they are connected. (temp measured with arduino is published good on openhab…)
client.publish("/beveiliging/voordeur", "CLOSED");
client.publish("/beveiliging/bijkeukengarage", "door-open");
i see the icons, but they do not react.
I’ve tried al lot, what am i doing wrong?
Hope somebody can help me.
hr_2
(hr2)
April 3, 2018, 5:36pm
2
A switch is for state ON/OFF, for OPEN/CLOSED use contact.
hr_2
(hr2)
April 3, 2018, 5:40pm
3
Define label="…[%s]" or leave label at sitemap and use the item-label.
every 3 seconds publish from arduino:
if(keerom==false){
client.publish("/beveiliging/voordeur", ":state:OPEN");
client.publish("/beveiliging/bijkeukengarage", "OPEN");
keerom=true;
} else {
client.publish("/beveiliging/voordeur", ":state:CLOSED");
client.publish("/beveiliging/bijkeukengarage", "CLOSED");
keerom=false;
}
demo.sitemap:
Frame label="Beveiliging"{
Text item=VoorDeur label="Voordeur"
Text item=BijkeukenGarage label="Bijkeuken > Garagedeur"
}
demo.items:
Contact VoorDeur "frontdoor [%s]" <frontdoor> {mqtt="<[mosquitto:/beveiliging/voordeur:state:OPEN],<[mosquitto:/beveiliging/voordeur:state:CLOSED]"}
Contact BijkeukenGarage "door [%s]" <door> {mqtt="<[mosquitto:/beveiliging/bijkeukengarage:state:OPEN],<[mosquitto:/beveiliging/bijkeukengarage:state:CLOSED]"}
Now the doors icons are closed but not changing
your code goes here
Solved!!! Happy!!!
Arduino code:
if(keerom==false){
client.publish("/beveiliging/voordeur", "OPEN");
client.publish("/beveiliging/bijkeukengarage", "OPEN");
client.publish("/klimaat/tempout", "28.5");
keerom=true;
} else {
client.publish("/beveiliging/voordeur", "CLOSED");
client.publish("/beveiliging/bijkeukengarage", "CLOSED");
client.publish("/klimaat/tempout", "19.3");
keerom=false;
}
demo.sitemap:
Frame label="Beveiliging"{
Text item=VoorDeur label="Voordeur [%s]" icon="frontdoor"
Text item=BijkeukenGarage label="Bijkeuken > Garagedeur" icon="door"
}
demo.items:
Contact VoorDeur "state [%s]" {mqtt="<[mosquitto:/beveiliging/voordeur:state:CLOSED:CLOSED],<[mosquitto:/beveiliging/voordeur:state:OPEN:OPEN]"}
Contact BijkeukenGarage "state [%s]" {mqtt="<[mosquitto:/beveiliging/bijkeukengarage:state:OPEN:OPEN],<[mosquitto:/beveiliging/bijkeukengarage:state:CLOSED:CLOSED]"}