diff options
Diffstat (limited to 'mqtt-controller/status.go')
-rw-r--r-- | mqtt-controller/status.go | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/mqtt-controller/status.go b/mqtt-controller/status.go new file mode 100644 index 0000000..f469256 --- /dev/null +++ b/mqtt-controller/status.go | |||
@@ -0,0 +1,80 @@ | |||
1 | package main | ||
2 | |||
3 | /* | ||
4 | shellies/announce <- coming online announcements | ||
5 | shellies/<deviceid>/info <- status endpoint | ||
6 | |||
7 | shellies/command -> publish to address all (announce, update, update_fw) | ||
8 | shellies/<deviceid>/command -> publish to address one | ||
9 | |||
10 | <i> is zero based | ||
11 | |||
12 | shellies/<deviceid>/relay/<i>/command (input: on, off, toggle) | ||
13 | |||
14 | shellies/<deviceid>/input/<i> (output: 0, 1) | ||
15 | shellies/<deviceid>/longpush/<i> (output: 0 short, 1 long) | ||
16 | shellies/<deviceid>/temperature (float, device temp in C) | ||
17 | shellies/<deviceid>/overtemperature (int, 1 if overtemp, 0 otherwise) | ||
18 | shellies/<deviceid>/relay/<i> (output: on, off, overpower) | ||
19 | shellies/<deviceid>/relay/<i>/power (float, instantaneous power in watts) | ||
20 | shellies/<deviceid>/relay/<i>/energy (int, watt-minute counter) | ||
21 | shellies/<deviceid>/relay/<i>/overpower_value (power in watts where overpower occurred) | ||
22 | */ | ||
23 | |||
24 | type ShellyInput struct { | ||
25 | Event string `json:"event"` // L=Long Press, S=Short Press, =None/Invalid | ||
26 | EventCount int `json:"event_cnt"` | ||
27 | CurrentState int `json:"input"` | ||
28 | } | ||
29 | |||
30 | type ShellyMeter struct { | ||
31 | EnergyCounters []float32 `json:"counters"` // Last 3 round minutes in watt-minute | ||
32 | Valid bool `json:"is_valid"` | ||
33 | Overpower float32 `json:"overpower"` // Value in Watts, on which an overpower condition is detected | ||
34 | Timestamp int `json:"timestamp"` // Last counter value reading time | ||
35 | Total int `json:"total"` // Total watt-minutes consumed | ||
36 | } | ||
37 | |||
38 | type ShellyRelay struct { | ||
39 | HasTimer bool `json:"has_timer"` | ||
40 | IsValid bool `json:"is_valid"` | ||
41 | IsOn bool `json:"ison"` | ||
42 | Overpower bool `json:"overpower"` | ||
43 | OverTemperature bool `json:"overtemperature"` | ||
44 | Source string `json:"source"` | ||
45 | TimerDuration int `json:"timer_duration"` | ||
46 | TimerRemaining int `json:"timer_remaining"` | ||
47 | TimerStarted int `json:"timer_started"` // Unix timestamp of start | ||
48 | } | ||
49 | |||
50 | type ShellyStatus struct { | ||
51 | Device Device | ||
52 | ConfigChangeCount int `json:"cfg_changed_cnt"` | ||
53 | Cloud struct { | ||
54 | Connected bool `json:"connected"` | ||
55 | Enabled bool `json:"enabled"` | ||
56 | } `json:"cloud"` | ||
57 | MQTT struct { | ||
58 | Connected bool `json:"connected"` | ||
59 | } `json:"mqtt"` | ||
60 | FilesystemFreeBytes int `json:"fs_free"` | ||
61 | FilesystemSizeBytes int `json:"fs_size"` | ||
62 | RAMFreeBytes int `json:"ram_free"` | ||
63 | RAMSizeBytes int `json:"ram_total"` | ||
64 | HasUpdate bool `json:"has_update"` | ||
65 | MacAddress string `json:"mac"` | ||
66 | OverTemperature bool `json:"overtemperature"` | ||
67 | TemperatureC float32 `json:"temperature"` | ||
68 | TemperatureStatus string `json:"temperature_status"` | ||
69 | Uptime int `json:"uptime"` | ||
70 | Voltage float32 `json:"voltage"` | ||
71 | WifiClient struct { | ||
72 | Connected bool `json:"connected"` | ||
73 | IP string `json:"ip"` | ||
74 | RSSI int `json:"rssi"` | ||
75 | SSID string `json:"ssid"` | ||
76 | } `json:"wifi_sta"` | ||
77 | Inputs []ShellyInput `json:"inputs"` | ||
78 | Meters []ShellyMeter `json:"meters"` | ||
79 | Relays []ShellyRelay `json:"relays"` | ||
80 | } | ||