For a binding, Java no rules, how can I read the status of a channel?
In this way I read ChannelType
if( channel.getAcceptedItemType().equals("Number:Temperature") ) {
// do stuff
}
State/value ?
For a binding, Java no rules, how can I read the status of a channel?
In this way I read ChannelType
if( channel.getAcceptedItemType().equals("Number:Temperature") ) {
// do stuff
}
State/value ?
Do you mean state or status? Those are different things. I think we can better help you if you explain what you want to achieve.
Hello,
Thanks for the reply.
I attach a piece of code.
After 500ms scheduler.schedule
I update the status with updateState(channel.getUID(), new StringType(PressureState.RELEASED.toString()));
case PRESSED_EXT:
// TODO send more EXT PRESSURE messages every 500ms untile RELEASE_EXT command
if (isCENPlus) {
updateState(channel.getUID(), new StringType(PressureState.RELEASED.toString()));
} else {
// Alfa 4 bridgeHandler.gateway.send(CENScenario.virtualStartPressure(deviceWhere,
// buttonNumber));
scheduler.schedule(() -> { // let's schedule a CEN virtual ext pressure OWN message
logger.debug("==OWN:ScenarioHandler== # " + deviceWhere
+ " sending CEN virtual ext pressure...");
updateState(channel.getUID(), new StringType(PressureState.RELEASED.toString()));
}, EXT_PRESS_INTERVAL, TimeUnit.MILLISECONDS);
}
break;
I have to add the if condition, because in the meantime the value could be changed.
channel.getState()
does not work
scheduler.schedule(() -> { // let's schedule a CEN virtual ext pressure OWN message
if (channel.getState() == PressureState.PRESSED) {
logger.debug(
"==OWN:ScenarioHandler== # " + deviceWhere + " sending CEN virtual release...");
updateState(channel.getUID(), new StringType(PressureState.RELEASED.toString()));
}
}, EXT_PRESS_INTERVAL, TimeUnit.MILLISECONDS);
openHAB does not cache the state for you. You must create your own Map<String,State>
for channelID->State caching in your thing handler. There are some cache related classes in the core to assist you.
Cheers, David