use of org.eclipse.smarthome.binding.astro.handler.AstroThingHandler in project smarthome by eclipse.
the class EventJob method run.
@Override
public void run() {
AstroThingHandler astroHandler = AstroHandlerFactory.getHandler(getThingUID());
if (checkNull(astroHandler, "AstroThingHandler is null")) {
return;
}
astroHandler.triggerEvent(channelID, event);
}
use of org.eclipse.smarthome.binding.astro.handler.AstroThingHandler in project smarthome by eclipse.
the class PublishPlanetJob method run.
@Override
public void run() {
AstroThingHandler astroHandler = AstroHandlerFactory.getHandler(getThingUID());
if (checkNull(astroHandler, "AstroThingHandler is null")) {
return;
}
astroHandler.publishDailyInfo();
}
use of org.eclipse.smarthome.binding.astro.handler.AstroThingHandler in project smarthome by eclipse.
the class SunPhaseJob method run.
@Override
public void run() {
AstroThingHandler astroHandler = AstroHandlerFactory.getHandler(getThingUID());
if (checkNull(astroHandler, "AstroThingHandler is null")) {
return;
}
Channel phaseNameChannel = astroHandler.getThing().getChannel(CHANNEL_ID_SUN_PHASE_NAME);
if (checkNull(phaseNameChannel, "Phase Name Channel is null")) {
return;
}
Planet planet = astroHandler.getPlanet();
if (planet != null && planet instanceof Sun) {
final Sun typedSun = (Sun) planet;
typedSun.getPhase().setName(sunPhaseName);
astroHandler.publishChannelIfLinked(phaseNameChannel.getUID());
}
}
use of org.eclipse.smarthome.binding.astro.handler.AstroThingHandler in project smarthome by eclipse.
the class AstroHandlerFactory method createHandler.
@Override
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
AstroThingHandler thingHandler = null;
if (thingTypeUID.equals(THING_TYPE_SUN)) {
thingHandler = new SunHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_MOON)) {
thingHandler = new MoonHandler(thing);
}
if (thingHandler != null) {
ASTRO_THING_HANDLERS.put(thing.getUID().toString(), thingHandler);
}
return thingHandler;
}
use of org.eclipse.smarthome.binding.astro.handler.AstroThingHandler in project smarthome by eclipse.
the class Job method scheduleEvent.
/**
* Schedules an {@link EventJob} instance
*
* @param thingUID the Thing UID
* @param astroHandler the {@link ThingHandler} instance
* @param eventAt the {@link Calendar} instance denoting scheduled instant
* @param events the event IDs to schedule
* @param channelId the channel ID
*/
public static void scheduleEvent(String thingUID, AstroThingHandler astroHandler, Calendar eventAt, List<String> events, String channelId, boolean configAlreadyApplied) {
boolean thingNull = checkNull(thingUID, "Thing UID is null");
boolean astroHandlerNull = checkNull(astroHandler, "AstroThingHandler is null");
boolean eventAtNull = checkNull(eventAt, "Scheduled Instant is null");
boolean eventsNull = checkNull(events, "Events list is null");
boolean channelIdNull = checkNull(channelId, "Channel ID is null");
if (thingNull || astroHandlerNull || eventAtNull || eventsNull || channelIdNull || events.isEmpty()) {
return;
}
final Calendar instant;
if (!configAlreadyApplied) {
final Channel channel = astroHandler.getThing().getChannel(channelId);
if (channel == null) {
LOGGER.warn("Cannot find channel '{}' for thing '{}'.", channelId, astroHandler.getThing().getUID());
return;
}
AstroChannelConfig config = channel.getConfiguration().as(AstroChannelConfig.class);
instant = applyConfig(eventAt, config);
} else {
instant = eventAt;
}
List<Job> jobs = events.stream().map(e -> new EventJob(thingUID, channelId, e)).collect(toList());
schedule(thingUID, astroHandler, new CompositeJob(thingUID, jobs), instant);
}
Aggregations