Hi Community,
I have some Rules Problem:
I Use Window Contacts wich have an On/Off Channel and for my Sitemaps etc I convert the On/Off to a Contact Item Open/Colosed:
rule “Buero”
when
Item Buero_Fenster changed
then
switch Buero_Fenster.state {
case ON:{Buero_Fensters.sendCommand(OPEN)}
case OFF:{Buero_Fensters.sendCommand(CLOSED)}
}
end
I have a lot of these Contacts to install now, so I dont want to wirte a Ruel for each:
New Rule:
rule “Fenster”
when
Member of gFe changed
then
var Fenster = triggeringItem.name + “s”
switch triggeringItem.state {
case ON:{Fenster.sendCommand(“OPEN”)}
case OFF:{Fenster.sendCommand(“CLOSED”)}
}
end
I have this (var itemName = triggeringItem.name + “something”) working for On/Off items but for the Contact Item it shows the following Log:
2020-08-19 07:34:58.987 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert ‘OPEN’ to a command type which item ‘Buero_Fensters’ accepts: [RefreshType].
Maybe I have just missed something
Anybody any Idea?
You’re doing something different in the second rule: you’re sending "OPEN" instead of OPEN
But ultimately it seems like this would be far easier if your Thing channel was a CONTACT type in the first place. But I don’t use the Zigbee binding, so not sure what’s involved, or if it’s even possible.
Type mismatch: cannot convert from OpenClosedType to String
Log:
Rule ‘Fenster’: An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(java.lang.String,java.lang.String) on instance: null
You really need to start looking in your openhab.log, it tells you a lot about problems it encounters with rules and can help you fix it.
I think you are saying -
You’ve got a Switch type Item, because that what the binding gives you.
That has an ON/OFF state, of course.
You would like to see that represented in your sitemap instead with text like “Open” or “Closed”, or maybe “Offnen” and “Zu”, right?
You don’t need a Contact Item for that, just a “translation” for the sitemap.
You will need to install the MAP transformation service add-on.
You will need to create a MAP file using a text editor, and place it in the correct /transform folder.
doorsw.map
OFF=zu
ON=offen
-=undefiniert
Now, tell your Item to use that map in its label [state presentation]
thanks for the support.
The log has no entries in this case only the on/off state which changes.
I already have Map Transformation working for my Sitemaps but I need the contact Item for the Window and Door icon to change dynamicly according to the state (showed as open or closed).
When I use the Window icon whith a switch item and Map transformaiton, in my sitemap the Icon is only static an with the contact it is dynamic, the value is showed correct (as in my map file).
What I tried to do was linking the Contact Item to an Switch Channel via Paper UI by selecting the Map Transformation.