public static void say(String text) { JsonMessaging messaging = new JsonMessaging(UUID.randomUUID(), "speak"); messaging.broadcast("event.speak", new SpeakAdvertisement(text, 100.0)); }
public void stop() { jsonMessaging.close(); } }
readAndScheduleTasks(); jsonMessaging = new JsonMessaging(UUID.randomUUID(), "events"); jsonMessaging.subscribe("event.scheduler.reload.tasks"); jsonMessaging.subscribe("event.scheduler.reload.sources"); jsonMessaging.subscribe("event.scheduler.stop"); jsonMessaging.subscribe("event.scheduler.start"); jsonMessaging.subscribe("event.scheduler.restart"); jsonMessaging.setNotification(new JsonNotification() { @Override public void onNotification(JsonEnvelope envelope) throws RuntimeException, SchedulerException, InterruptedException, ClassNotFoundException { jsonMessaging.start(); } catch (final Throwable t) { LOGGER.error("Error in Scheduler!");
jsonMessaging = new JsonMessaging(UUID.randomUUID(), "weather"); jsonMessaging.subscribe("event.weather.get"); jsonMessaging.setNotification(envelope -> { jsonMessaging.response(envelope, response); jsonMessaging.broadcast("event.weather", broadcast); jsonMessaging.start();
jsonMessaging.subscribe(event.getSubject()); LOGGER.debug("Subscribe to subject: " + event.getSubject()); jsonMessaging.subscribe("event.command"); jsonMessaging.subscribe("event.script.get"); jsonMessaging.subscribe("event.script.save"); jsonMessaging.subscribe("event.script.delete"); jsonMessaging.subscribe("event.script.list"); jsonMessaging.subscribe("event.reload"); jsonMessaging.setNotification(new JsonNotification() { jsonMessaging.start(); } catch (final RuntimeException t) { LOGGER.error("Error in Events!");
public static void level(String device, double level) { messaging.broadcast("event.speak.volume.set", new ChangeVolumeAdvertisement(level, device)); } }
private void reloadService() throws RuntimeException { LOGGER.info("Reload event service"); // unsubscribe current events for (Event event : events) { jsonMessaging.unsubscribe(event.getSubject()); LOGGER.debug("Unsubscribe from subject: " + event.getSubject()); } events = Ebean.find(Event.class).findList(); // subscribe to events from db for (Event event : events) { jsonMessaging.subscribe(event.getSubject()); LOGGER.debug("Subscribe from subject: " + event.getSubject()); } // take pause to save/remove new entity try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } // load all scripts, compile and put into map compiledScriptMap = loadAndCompile(events); LOGGER.info("Reload event service done"); }
messaging = new JsonMessaging(UUID.randomUUID(), "devices-noolite-rx"); rx = new RX2164(); rx.open();
jsFile = new File("./scripts/" + advertisement.getName()); jsonMessaging.response(envelope, new EventResponseGetScriptAdvertisement(FileUtils.readFileToString(jsFile))); response.setScripts((List<File>) FileUtils.listFiles(jsFile, new String[]{"js"}, false)); jsonMessaging.response(envelope, response);
jsonMessaging = new JsonMessaging(UUID.randomUUID(), "witai"); jsonMessaging.subscribe("event.speak.recognized"); jsonMessaging.setNotification(new JsonNotification() { jsonMessaging.start();
public static void off(String device) { messaging.broadcast("event.speak.volume.set", new ChangeVolumeAdvertisement(0D, device)); }
pc.open(); jsonMessaging = new JsonMessaging(UUID.randomUUID(), "devices-noolite-tx"); jsonMessaging.subscribe("event.devices.setvalue"); jsonMessaging.subscribe("event.devices.noolite.value.set"); jsonMessaging.subscribe("event.devices.noolite.tx.bindchannel"); jsonMessaging.subscribe("event.devices.noolite.tx.unbindchannel"); jsonMessaging.setNotification(new JsonNotification() { jsonMessaging.start(); } catch (final Throwable t) { LOGGER.error("Error in Noolite-TX!");
public static void say(String text, String device) { JsonMessaging messaging = new JsonMessaging(UUID.randomUUID(), "speak"); messaging.broadcast("event.speak", new SpeakAdvertisement(text, 100.0, device)); } }
public void stop() { jsonMessaging.close(); } }
public static void on(String device) { messaging.broadcast("event.speak.volume.set", new ChangeVolumeAdvertisement(100D, device)); }
jsonMessaging = new JsonMessaging(UUID.randomUUID(), "devices-noolite-rx-internal"); jsonMessaging.subscribe("event.devices.noolite.rx.bindchannel"); jsonMessaging.subscribe("event.devices.noolite.rx.unbindchannel"); jsonMessaging.subscribe("event.devices.noolite.rx.unbindallchannel"); jsonMessaging.setNotification(envelope -> { jsonMessaging.start(); } catch (final Throwable t) { LOGGER.error("Error in Noolite-RX-Internal!");
@Override public void execute(JobExecutionContext param) throws JobExecutionException { JobDataMap data = param.getJobDetail().getJobDataMap(); String subject = data.getString("subject"); String obj = data.getString("obj"); LOGGER.debug("Run task with subject: " + subject); CommandAdvertisement advertisement = gson.fromJson(obj, CommandAdvertisement.class); new JsonMessaging(UUID.randomUUID()).broadcast(subject, advertisement); }
public void stop() { jsonMessaging.close(); } }
public static void set(String name, int value) { Device device = Ebean.find(Device.class).where().eq("friendlyname", name).findUnique(); if (device == null) { LOGGER.error("Device not found: " + name); return; } if (value == 255) messaging.broadcast("event.devices.setvalue", new GenericAdvertisement("DeviceOn", device.getUuid())); else messaging.broadcast("event.devices.setvalue", new GenericAdvertisement("DeviceOff", device.getUuid())); } }
JsonMessaging jsonMessaging = new JsonMessaging(UUID.randomUUID(), "plugins"); jsonMessaging.subscribe("event.plugin.start"); jsonMessaging.subscribe("event.plugin.stop"); jsonMessaging.subscribe("event.plugin.restart"); jsonMessaging.subscribe("event.plugin"); jsonMessaging.setNotification(envelope -> { jsonMessaging.start();