use of org.eclipse.smarthome.core.thing.ThingStatus in project smarthome by eclipse.
the class MagicDelayedOnlineHandler method handleCommand.
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (channelUID.getId().equals("number")) {
if (command instanceof DecimalType) {
DecimalType cmd = (DecimalType) command;
int cmdInt = cmd.intValue();
ThingStatus status = cmdInt > 0 ? ThingStatus.ONLINE : ThingStatus.OFFLINE;
int waitTime = Math.abs(cmd.intValue());
scheduler.schedule(() -> updateStatus(status), waitTime, TimeUnit.SECONDS);
}
}
}
use of org.eclipse.smarthome.core.thing.ThingStatus in project smarthome by eclipse.
the class RuleTriggerManager method internalGetThingRules.
private Iterable<Rule> internalGetThingRules(TriggerTypes triggerType, String thingUid, ThingStatus oldStatus, ThingStatus newStatus) {
List<Rule> result = new ArrayList<>();
Iterable<Rule> rules = getAllRules(triggerType, thingUid);
switch(triggerType) {
case THINGUPDATE:
for (Rule rule : rules) {
for (EventTrigger t : rule.getEventtrigger()) {
if (t instanceof ThingStateUpdateEventTrigger) {
ThingStateUpdateEventTrigger tt = (ThingStateUpdateEventTrigger) t;
if (tt.getThing().equals(thingUid)) {
String stateString = tt.getState();
if (stateString != null) {
ThingStatus triggerState = ThingStatus.valueOf(stateString);
if (!newStatus.equals(triggerState)) {
continue;
}
}
result.add(rule);
}
}
}
}
break;
case THINGCHANGE:
for (Rule rule : rules) {
for (EventTrigger t : rule.getEventtrigger()) {
if (t instanceof ThingStateChangedEventTrigger) {
ThingStateChangedEventTrigger ct = (ThingStateChangedEventTrigger) t;
if (ct.getThing().equals(thingUid)) {
String oldStatusString = ct.getOldState();
if (oldStatusString != null) {
ThingStatus triggerOldState = ThingStatus.valueOf(oldStatusString);
if (!oldStatus.equals(triggerOldState)) {
continue;
}
}
String newStatusString = ct.getNewState();
if (newStatusString != null) {
ThingStatus triggerNewState = ThingStatus.valueOf(newStatusString);
if (!newStatus.equals(triggerNewState)) {
continue;
}
}
result.add(rule);
}
}
}
}
break;
default:
break;
}
return result;
}
use of org.eclipse.smarthome.core.thing.ThingStatus in project smarthome by eclipse.
the class AutomaticInboxProcessor method receiveTypedEvent.
@Override
public void receiveTypedEvent(ThingStatusInfoChangedEvent event) {
if (autoIgnore) {
Thing thing = thingRegistry.get(event.getThingUID());
ThingStatus thingStatus = event.getStatusInfo().getStatus();
autoIgnore(thing, thingStatus);
}
}
use of org.eclipse.smarthome.core.thing.ThingStatus in project smarthome by eclipse.
the class RuleEngineImpl method receiveThingStatus.
private void receiveThingStatus(ThingStatusInfoChangedEvent event) {
String thingUid = event.getThingUID().getAsString();
ThingStatus oldStatus = event.getOldStatusInfo().getStatus();
ThingStatus newStatus = event.getStatusInfo().getStatus();
Iterable<Rule> rules = triggerManager.getRules(THINGUPDATE, thingUid, newStatus);
executeRules(rules);
if (oldStatus != newStatus) {
rules = triggerManager.getRules(THINGCHANGE, thingUid, oldStatus, newStatus);
executeRules(rules, oldStatus);
}
}
Aggregations