Files
aqhomecontrol/aqhome/data
Martin Preuss 17d4ce5125 Change AQH_Value field NameForDriver to Name and make it only contain the value name.
Previously this field contained the device name, too. This would make it
necessary for drivers to remove the device part of the name when SetValue
is called. Instead the device name is now always provided by the driver in
the appropriate field DeviceNameForDriver.
2023-10-03 13:31:05 +02:00
..
2023-09-17 19:24:06 +02:00
2023-08-14 02:00:37 +02:00

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