summaryrefslogtreecommitdiff
path: root/doc/database.md
blob: ba5a3d23591485924c5f1ed32f811078d41af3d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Databases

## Inverter database

ClickHouse tables:
```sql
CREATE TABLE status (
	ClientTime DateTime,
	ReceivedTime DateTime,
	HomeID UInt16,
	GridVoltage UInt16,
	GridFrequency UInt16,
	ACOutputVoltage UInt16,
	ACOutputFrequency UInt16,
	ACOutputApparentPower UInt16,
	ACOutputActivePower UInt16,
	OutputLoadPercent UInt8,
	BatteryVoltage UInt16,
	BatteryVoltageSCC UInt16,
	BatteryVoltageSCC2 UInt16,
	BatteryDischargingCurrent UInt16,
	BatteryChargingCurrent UInt16,
	BatteryCapacity UInt8,
	HeatSinkTemp UInt16,
	MPPT1ChargerTemp UInt16,
	MPPT2ChargerTemp UInt16,
	PV1InputPower UInt16,
	PV2InputPower UInt16,
	PV1InputVoltage UInt16,
	PV2InputVoltage UInt16,
	MPPT1ChargerStatus Enum8('Abnormal' = 0, 'NotCharging' = 1, 'Charging' = 2),
	MPPT2ChargerStatus Enum8('Abnormal' = 0, 'NotCharging' = 1, 'Charging' = 2),
	BatteryPowerDirection Enum8('DoNothing' = 0, 'Charge' = 1, 'Discharge' = 2),
	DCACPowerDirection Enum8('DoNothing' = 0, 'AC/DC' = 1, 'DC/AC' = 2),
	LinePowerDirection Enum8('DoNothing' = 0, 'Input' = 1, 'Output' = 2),
	LoadConnected Enum8('Disconnected' = 0, 'Connected' = 1)
) ENGINE = MergeTree()
PARTITION BY toYYYYMMDD(ReceivedTime)
ORDER BY (HomeID, ReceivedTime);

CREATE TABLE generation (
	ClientTime DateTime,
	ReceivedTime DateTime,
	HomeID UInt16,
	Watts UInt16
) ENGINE = MergeTree()
PARTITION BY toYYYYMMDD(ReceivedTime)
ORDER BY (HomeID, ReceivedTime);
```


## Sensors database

ClickHouse tables:
```sql
CREATE TABLE temp_table_name (
    ClientTime DateTime,
    ReceivedTime DateTime,
    HomeID UInt16,
    Temperature Int16,
    RelativeHumidity UInt16
) ENGINE = MergeTree()
PARTITION BY toYYYYMMDD(ReceivedTime)
ORDER BY (HomeID, ReceivedTime);
```