String customDevice::get(Topic &topic) { /* ~/get └─device (level 2) └─sensor1 (level 3) */ logging.debug("device get topic " + topic.topic_asString()); if (topic.getItemCount() != 4) // ~/get/device/sensor1 return TOPIC_NO; if (topic.itemIs(3, "sensor1")) { return String(measure()); } else { return TOPIC_NO; } }
String customDevice::set(Topic &topic) { /* ~/set └─device (level 2) └─yourItem (level 3) */ logging.debug("device set topic " + topic.topic_asString() + " to " + topic.arg_asString()); if (topic.getItemCount() != 4) // ~/set/device/yourItem return TOPIC_NO; if (topic.itemIs(3, "yourItem")) { return TOPIC_OK; } else { return TOPIC_NO; } }
String customDevice::set(Topic &topic) { /* ~/set └─device (level 2) └─deviceCFG (level 3) └─index (level 4) individual setting └─value (level 4) individual setting └─scanBus (level 4) scan 1W-Bus for new devices */ logging.debug("device set topic " + topic.topic_asString() + " to " + topic.arg_asString()); String ret = TOPIC_NO; if (topic.itemIs(3, "deviceCFG")) { //modify dashboard------------------- if (topic.itemIs(4, "addItem")) { modifyDashboard(); return TOPIC_OK; } } return ret; }