room: - id - name - description - colour device - id - name - room - location - description mqtt-topic: - id - deviceId - mqttTopic - mqttDataType (num, json) value: - id - topicId - value type (temp, humidity, speed, door, length, width, counter, gauge) - units - dataPath (for JSON) datapoint: - value id - timestamp - value lastDatapoint: (DB: no rollback, otherwise db would double in size) - module id - timestamp - value Processing MQTT publish messages: - create data point - set timestamp in data point - find MQTT_TOPIC for topic string - mqttType: - num: - lookup first value - store data in data point - json: parse data - for every VALUE assigned to that topic: - store data in data point - write data point to long term db - write data point to lastValues db Storage API: - handleMqttPublish(AQH_STORAGE *st, const char *topic, const char *value) - addDevice(AQH_STORAGE *st, AQH_DEVICE *dev) - getDeviceList(const AQH_STORAGE *st) - getDeviceById(const AQH_STORAGE *st, uint32_t id) - addMqttTopic(AQH_STORAGE *st, AQH_MQTT_TOPIC *t); - getMqttTopicList(const AQH_STORAGE *st) - getMqttTopicById(const AQH_STORAGE *st, uint32_t id) - getMqttTopicByTopic(const AQH_STORAGE *st, const char *topic) - addValue(AQH_STORAGE *st, AQH_VALUE *value) - getValueList(const AQH_STORAGE *st) - getValueById(const AQH_STORAGE *st, uint32_t id) datafile: - valueId - filename - number of entries - fd - getNumOfEntries() - readRecord(id, &record) - addRecord(record) datarecord in file: - 8 bytes timestamp - 8 bytes value