@Override public String getAWSSecretKey() { return cfg.get("ivonaSecretKey"); } };
/** * Default constructor which loads properties from different storages. */ private Config() { synchronized (Config.class) { if (propertyMap != null) { return; } propertyMap = new ConcurrentHashMap<>(); loadPropertiesFromClassPath("/conf/iris-default.properties"); if (!loadPropertiesFromClassPath("/conf/iris-extended.properties")) { if (!loadPropertiesFromFileSystem("/conf/iris-extended.properties")) { loadPropertiesFromFileSystem("./conf/main.property"); } } loadPropertiesFromDatabase(); } }
@Override public void start() { Config config = Config.getInstance(); LOGGER.info("[Plugin] iris-devices-zwave plugin started!"); if (config.get("zwaveEnabled").equals("1")) { LOGGER.info("ZWave support enabled. Starting"); service = new ZWaveService(); } }
public WeatherService() { Status status = new Status("Weather"); if (status.checkExist()) { status.running(); } else { status.addIntoDB("Weather", "Service that getting current weather"); LOGGER.info("Weather service started (LAT: " + conf.get("weatherLatitude") + ", LON: " + conf.get("weatherLongitude") + ")"); jsonMessaging = new JsonMessaging(UUID.randomUUID(), "weather"); jsonMessaging.subscribe("event.weather.get"); jsonMessaging.setNotification(envelope -> { if (envelope.getObject() instanceof GenericAdvertisement) { GenericAdvertisement advertisement = envelope.getObject(); switch (advertisement.getLabel()) { DBLogger.info("Getting weather..."); ForecastIO fio = new ForecastIO(conf.get("weatherApi")); fio.setUnits(ForecastIO.UNITS_SI); fio.getForecast(conf.get("weatherLatitude"), conf.get("weatherLongitude")); fio.setLang(ForecastIO.LANG_RUSSIAN); GenericAdvertisement response = new GenericAdvertisement(); response.setData(data);
public SpeakService() { Status status = new Status("Speak"); if (status.checkExist()) { status.running(); } else { status.addIntoDB("Speak", "Service that synthesize text to speak"); final Config conf = Config.getInstance(); String tts = conf.get("ttsEngine"); synthesiser = new GoogleSynthesiser(conf.get("googleKey")); break; case "yandex": synthesiser = new YandexSynthesiser(conf.get("yandexKey")); break; case "ivona": synthesiser = new IvonaSynthesiser(); break; default: synthesiser.setLanguage(conf.get("language")); jsonMessaging = new JsonMessaging(UUID.randomUUID(), "speak"); jsonMessaging.subscribe("event.speak"); jsonMessaging.subscribe("event.speak.volume.set"); jsonMessaging.setNotification(new JsonNotification() { @Override
public WitAiService() final Config cfg = Config.getInstance(); final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); Status status = new Status("AI"); if (status.checkExist()) { status.running(); } else { status.addIntoDB("AI", "Wit.AI service recognition"); jsonMessaging = new JsonMessaging(UUID.randomUUID(), "witai"); jsonMessaging.subscribe("event.speak.recognized"); jsonMessaging.setNotification(new JsonNotification() { jsonMessaging.start(); status.crashed(); t.printStackTrace();
public ZWaveService() { Status status = new Status("ZWave"); if (status.checkExist()) { status.running(); } else { status.addIntoDB("ZWave", "Service that comminicate with ZWave devices"); messaging = new JsonMessaging(UUID.randomUUID(), "devices-zwave"); final Options options = Options.create(config.get("openzwaveCfgPath"), "", ""); options.addOptionBool("ConsoleOutput", Boolean.parseBoolean(config.get("zwaveDebug"))); options.addOptionString("UserPath", "conf/", true); options.lock(); manager.addDriver(config.get("zwavePort")); if (Manager.get().isNodeFailed(homeId, ZWaveDevice.getNode())) { LOGGER.info("Setting node " + ZWaveDevice.getNode() + " to DEAD state"); ZWaveDevice.setStatus("dead"); ZWaveDevice.save(); if (!Manager.get().isNodeAwake(homeId, ZWaveDevice.getNode())) { LOGGER.info("Setting node " + ZWaveDevice.getNode() + " to SLEEP state"); ZWaveDevice.setStatus("sleeping"); Manager.get().refreshNodeInfo(homeId, ZWaveDevice.getNode()); ZWaveDevice.save();
@Override public void onNotification(JsonEnvelope envelope) { if (envelope.getObject() instanceof SpeakRecognizedAdvertisement) SpeakRecognizedAdvertisement advertisement = envelope.getObject(); String url = "https://api.wit.ai/message?q=" + URLEncoder.encode(advertisement.getText(), "UTF-8"); httpget.addHeader("Authorization", "Bearer " + cfg.get("witaiKey")); Double confidence = json.getOutcome().getConfidence(); String object = json.getOutcome().getEntities().get("object").getValue(); LOGGER.info("Get response from AI: " + json.getMsg_body() + " to object: " + object); jsonMessaging.broadcast("event.ai.response.object." + object, new AIResponseAdvertisement(json)); + " from " + envelope.getSenderInstance() + " to " + envelope.getReceiverInstance() + " at '" + envelope.getSubject() + ": " + envelope.getObject());
@Override public void onNotification(JsonEnvelope envelope) throws IOException, JavaLayerException { if (envelope.getObject() instanceof SpeakAdvertisement) { SpeakAdvertisement advertisement = envelope.getObject(); Speaks speak = new Speaks(); speak.setText(advertisement.getText()); speak.setConfidence(advertisement.getConfidence()); speak.setDevice(advertisement.getDevice()); } else if (envelope.getObject() instanceof ChangeVolumeAdvertisement) { ChangeVolumeAdvertisement advertisement = envelope.getObject(); if (advertisement.getDevice().equals("server") || advertisement.getDevice().equals("all")) { LOGGER.info("Setting sound volume level to " + advertisement.getLevel()); if (advertisement.getLevel() == 0.0) { conf.set("silence", "1"); } else { conf.set("silence", "0"); + " from " + envelope.getSenderInstance() + " to " + envelope.getReceiverInstance() + " at '" + envelope.getSubject() + ": " + envelope.getObject());
homeId = notification.getHomeId(); LOGGER.info("Driver ready. Home ID: " + homeId); messaging.broadcast("event.devices.zwave.driver.ready", new GenericAdvertisement("ZWaveDriverReady", homeId)); break; case DRIVER_FAILED: LOGGER.info("Driver failed"); messaging.broadcast("event.devices.zwave.driver.failed", new GenericAdvertisement("ZWaveDriverFailed")); break; case DRIVER_RESET: LOGGER.info("Driver reset"); messaging.broadcast("event.devices.zwave.driver.reset", new GenericAdvertisement("ZWaveDriverReset")); break; case AWAKE_NODES_QUERIED: LOGGER.info("Awake nodes queried"); ready = true; messaging.broadcast("event.devices.zwave.awakenodesqueried", new GenericAdvertisement("ZWaveAwakeNodesQueried")); break; case ALL_NODES_QUERIED: manager.writeConfig(homeId); ready = true; messaging.broadcast("event.devices.zwave.allnodesqueried", new GenericAdvertisement("ZWaveAllNodesQueried")); break; case ALL_NODES_QUERIED_SOME_DEAD: LOGGER.info("All node queried, some dead"); manager.writeConfig(homeId); messaging.broadcast("event.devices.zwave.allnodesqueriedsomedead", new GenericAdvertisement("ZWaveAllNodesQueriedSomeDead")); break; case POLLING_ENABLED:
ZWaveDevice = new Device(); ZWaveDevice.setInternalType(type); ZWaveDevice.setSource("zwave"); ZWaveDevice.setInternalName("zwave/" + type + "/" + notification.getNodeId()); ZWaveDevice.setType(Manager.get().getNodeType(notification.getHomeId(), notification.getNodeId())); ZWaveDevice.setNode(notification.getNodeId()); ZWaveDevice.setUuid(uuid); ZWaveDevice.setManufName(manufName); ZWaveDevice.setProductName(productName); ZWaveDevice.setStatus(state); ZWaveDevice.addValue(new DeviceValue( label, uuid, String.valueOf(Utils.getValue(notification.getValueId())), Utils.getValueType(notification.getValueId()), Manager.get().getValueUnits(notification.getValueId()), notification.getValueId(), DeviceValue beaming = new DeviceValue(); beaming.setLabel("beaming"); beaming.setValueId("{ }"); beaming.setValue(String.valueOf(Manager.get().isNodeBeamingDevice(homeId, ZWaveDevice.getNode()))); beaming.setReadonly(true); ZWaveDevice.addValue(beaming);
if (conf.get("silence").equals("0")) { if (speak.getDevice().equals("all") || speak.getDevice().equals("server")) { LOGGER.debug("Confidence: " + speak.getConfidence()); LOGGER.debug("Text: " + speak.getText()); LOGGER.debug("Device: " + speak.getDevice()); speaks.getText().equals(speak.getText()) && speaks.getConfidence().equals(100D) cacheId = speaks.getCache(); result = synthesiser.getMP3Data(speak.getText()); speak.setCache(cacheIdent); speak.save(); player.play(); player.close(); speak.save(); LOGGER.info("Ignored. Request to play on device: " + speak.getDevice()); status.crashed(); t.printStackTrace();
@Override public void start() { LOGGER.info("[Plugin] iris-ai plugin started!"); Config cfg = Config.getInstance(); if (cfg.get("witaiEnabled").equals("1")) { witai = new WitAiService(); } else { LOGGER.info("No AI specified in config file"); } }
@Override public String getAWSAccessKeyId() { return cfg.get("ivonaAccessKey"); }
@Override public void start() { Config config = Config.getInstance(); LOGGER.info("[Plugin] iris-devices-noolite plugin started!"); if (config.get("nooliteEnabled").equals("1")) { LOGGER.info("NooLite support enabled. Starting"); if (config.get("nooliteTXPresent").equals("1")) { LOGGER.info("NooLite TX support enabled. Starting"); txService = new NooliteTXService(); } if (config.get("nooliteRXPresent").equals("1")) { LOGGER.info("NooLite RX support enabled. Starting"); rxService = new NooliteRXService(); } } }
Voice voice = new Voice(); voice.setName(cfg.get("ivonaVoice")); input.setData(synthText);
public JsonConnection() { // Create a ConnectionFactory ConnectionFactory connectionFactory = new ConnectionFactory(); // Create a Connection try { Config config = Config.getInstance(); // Create a ConnectionFactory connectionFactory.setHost(config.get("AMQPhost")); connectionFactory.setPort(Integer.valueOf(config.get("AMQPport"))); connectionFactory.setUsername(config.get("AMQPuser")); connectionFactory.setPassword(config.get("AMQPpasswd")); /* The AMQ connection. */ Connection connection = connectionFactory.newConnection(); channel = connection.createChannel(); // Create exchange channel.exchangeDeclare("iris", "topic", true); } catch (IOException | TimeoutException e) { LOGGER.error("Error while connection to AMQP broker: " + e.getMessage()); System.exit(1); } }