use of org.eclipse.smarthome.binding.astro.internal.model.Planet in project smarthome by eclipse.
the class DailyJobMoon method run.
@Override
public void run() {
handler.publishDailyInfo();
String thingUID = getThingUID();
LOGGER.info("Scheduled Astro event-jobs for thing {}", thingUID);
Planet planet = handler.getPlanet();
if (planet == null) {
LOGGER.error("Planet not instantiated");
return;
}
Moon moon = (Moon) planet;
scheduleEvent(thingUID, handler, moon.getRise().getStart(), EVENT_START, EVENT_CHANNEL_ID_RISE, false);
scheduleEvent(thingUID, handler, moon.getSet().getEnd(), EVENT_END, EVENT_CHANNEL_ID_SET, false);
MoonPhase moonPhase = moon.getPhase();
scheduleEvent(thingUID, handler, moonPhase.getFirstQuarter(), EVENT_PHASE_FIRST_QUARTER, EVENT_CHANNEL_ID_MOON_PHASE, false);
scheduleEvent(thingUID, handler, moonPhase.getThirdQuarter(), EVENT_PHASE_THIRD_QUARTER, EVENT_CHANNEL_ID_MOON_PHASE, false);
scheduleEvent(thingUID, handler, moonPhase.getFull(), EVENT_PHASE_FULL, EVENT_CHANNEL_ID_MOON_PHASE, false);
scheduleEvent(thingUID, handler, moonPhase.getNew(), EVENT_PHASE_NEW, EVENT_CHANNEL_ID_MOON_PHASE, false);
Eclipse eclipse = moon.getEclipse();
scheduleEvent(thingUID, handler, eclipse.getPartial(), EVENT_ECLIPSE_PARTIAL, EVENT_CHANNEL_ID_ECLIPSE, false);
scheduleEvent(thingUID, handler, eclipse.getTotal(), EVENT_ECLIPSE_TOTAL, EVENT_CHANNEL_ID_ECLIPSE, false);
scheduleEvent(thingUID, handler, moon.getPerigee().getDate(), EVENT_PERIGEE, EVENT_CHANNEL_ID_PERIGEE, false);
scheduleEvent(thingUID, handler, moon.getApogee().getDate(), EVENT_APOGEE, EVENT_CHANNEL_ID_APOGEE, false);
}
use of org.eclipse.smarthome.binding.astro.internal.model.Planet 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.internal.model.Planet in project smarthome by eclipse.
the class DailyJobSun method run.
@Override
public void run() {
handler.publishDailyInfo();
String thingUID = getThingUID();
LOGGER.info("Scheduled Astro event-jobs for thing {}", thingUID);
Planet planet = handler.getPlanet();
if (planet == null) {
LOGGER.error("Planet not instantiated");
return;
}
Sun sun = (Sun) planet;
scheduleRange(thingUID, handler, sun.getRise(), EVENT_CHANNEL_ID_RISE);
scheduleRange(thingUID, handler, sun.getSet(), EVENT_CHANNEL_ID_SET);
scheduleRange(thingUID, handler, sun.getNoon(), EVENT_CHANNEL_ID_NOON);
scheduleRange(thingUID, handler, sun.getNight(), EVENT_CHANNEL_ID_NIGHT);
scheduleRange(thingUID, handler, sun.getMorningNight(), EVENT_CHANNEL_ID_MORNING_NIGHT);
scheduleRange(thingUID, handler, sun.getAstroDawn(), EVENT_CHANNEL_ID_ASTRO_DAWN);
scheduleRange(thingUID, handler, sun.getNauticDawn(), EVENT_CHANNEL_ID_NAUTIC_DAWN);
scheduleRange(thingUID, handler, sun.getCivilDawn(), EVENT_CHANNEL_ID_CIVIL_DAWN);
scheduleRange(thingUID, handler, sun.getAstroDusk(), EVENT_CHANNEL_ID_ASTRO_DUSK);
scheduleRange(thingUID, handler, sun.getNauticDusk(), EVENT_CHANNEL_ID_NAUTIC_DUSK);
scheduleRange(thingUID, handler, sun.getCivilDusk(), EVENT_CHANNEL_ID_CIVIL_DUSK);
scheduleRange(thingUID, handler, sun.getEveningNight(), EVENT_CHANNEL_ID_EVENING_NIGHT);
scheduleRange(thingUID, handler, sun.getDaylight(), EVENT_CHANNEL_ID_DAYLIGHT);
SunEclipse eclipse = sun.getEclipse();
scheduleEvent(thingUID, handler, eclipse.getPartial(), EVENT_ECLIPSE_PARTIAL, EVENT_CHANNEL_ID_ECLIPSE, false);
scheduleEvent(thingUID, handler, eclipse.getTotal(), EVENT_ECLIPSE_TOTAL, EVENT_CHANNEL_ID_ECLIPSE, false);
scheduleEvent(thingUID, handler, eclipse.getRing(), EVENT_ECLIPSE_RING, EVENT_CHANNEL_ID_ECLIPSE, false);
// schedule republish jobs
schedulePublishPlanet(thingUID, handler, sun.getZodiac().getEnd());
schedulePublishPlanet(thingUID, handler, sun.getSeason().getNextSeason());
// schedule phase jobs
scheduleSunPhase(thingUID, handler, SUN_RISE, sun.getRise().getStart());
scheduleSunPhase(thingUID, handler, SUN_SET, sun.getSet().getStart());
scheduleSunPhase(thingUID, handler, NIGHT, sun.getNight().getStart());
scheduleSunPhase(thingUID, handler, DAYLIGHT, sun.getDaylight().getStart());
scheduleSunPhase(thingUID, handler, ASTRO_DAWN, sun.getAstroDawn().getStart());
scheduleSunPhase(thingUID, handler, NAUTIC_DAWN, sun.getNauticDawn().getStart());
scheduleSunPhase(thingUID, handler, CIVIL_DAWN, sun.getCivilDawn().getStart());
scheduleSunPhase(thingUID, handler, ASTRO_DUSK, sun.getAstroDusk().getStart());
scheduleSunPhase(thingUID, handler, NAUTIC_DUSK, sun.getNauticDusk().getStart());
scheduleSunPhase(thingUID, handler, CIVIL_DUSK, sun.getCivilDusk().getStart());
}
Aggregations