wled_json_api_library/structures/cfg/
cfg_if2.rs

1use serde;
2use serde::{Serialize, Deserialize};
3use serde_repr::{Deserialize_repr, Serialize_repr};
4use crate::structures::none_function;
5
6
7
8#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct If2 {
11    #[serde(skip_serializing_if = "Option::is_none")]
12    #[serde(default = "none_function")]
13    pub sync: Option<Sync>,
14    #[serde(skip_serializing_if = "Option::is_none")]
15    #[serde(default = "none_function")]
16    pub nodes: Option<Nodes>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    #[serde(default = "none_function")]
19    pub live: Option<Live>,
20    #[serde(skip_serializing_if = "Option::is_none")]
21    #[serde(default = "none_function")]
22    pub va: Option<Va>,
23    #[serde(skip_serializing_if = "Option::is_none")]
24    #[serde(default = "none_function")]
25    pub mqtt: Option<Mqtt>,
26    #[serde(skip_serializing_if = "Option::is_none")]
27    #[serde(default = "none_function")]
28    pub hue: Option<Hue>,
29    #[serde(skip_serializing_if = "Option::is_none")]
30    #[serde(default = "none_function")]
31    pub ntp: Option<Ntp>,
32}
33
34#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
35#[serde(rename_all = "camelCase")]
36pub struct Sync {
37    /// WLED notifier default port
38    #[serde(skip_serializing_if = "Option::is_none")]
39    #[serde(default = "none_function")]
40    pub port0: Option<u16>,
41
42    /// WLED notifier supplemental port
43    #[serde(skip_serializing_if = "Option::is_none")]
44    #[serde(default = "none_function")]
45    pub port1: Option<u16>,
46
47    /// WLED notifier receive info
48    #[serde(skip_serializing_if = "Option::is_none")]
49    #[serde(default = "none_function")]
50    pub recv: Option<Recv>,
51
52    /// WLED notifier send info
53    #[serde(skip_serializing_if = "Option::is_none")]
54    #[serde(default = "none_function")]
55    pub send: Option<Send>,
56}
57
58#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
59#[serde(rename_all = "camelCase")]
60pub struct Recv {
61
62    /// apply brightness from incoming notifications
63    #[serde(skip_serializing_if = "Option::is_none")]
64    #[serde(default = "none_function")]
65    pub bri: Option<bool>,
66
67    /// apply color
68    #[serde(skip_serializing_if = "Option::is_none")]
69    #[serde(default = "none_function")]
70    pub col: Option<bool>,
71
72    /// apply effects setup
73    #[serde(skip_serializing_if = "Option::is_none")]
74    #[serde(default = "none_function")]
75    pub fx: Option<bool>,
76
77    /// sync receive groups this instance belongs to (bit mapped)
78    #[serde(skip_serializing_if = "Option::is_none")]
79    #[serde(default = "none_function")]
80    pub grp: Option<u8>,
81
82    /// apply segment options
83    #[serde(skip_serializing_if = "Option::is_none")]
84    #[serde(default = "none_function")]
85    pub seg: Option<bool>,
86
87    /// apply segment bounds (start, stop, offset)
88    #[serde(skip_serializing_if = "Option::is_none")]
89    #[serde(default = "none_function")]
90    pub sb: Option<bool>,
91}
92
93#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
94#[serde(rename_all = "camelCase")]
95pub struct Send {
96    /// send notification if change via UI or HTTP API
97    #[serde(skip_serializing_if = "Option::is_none")]
98    #[serde(default = "none_function")]
99    pub dir: Option<bool>,
100
101    /// send if updated by button or infrared remote
102    #[serde(skip_serializing_if = "Option::is_none")]
103    #[serde(default = "none_function")]
104    pub btn: Option<bool>,
105
106    /// send notification if updated via Alexa
107    #[serde(skip_serializing_if = "Option::is_none")]
108    #[serde(default = "none_function")]
109    pub va: Option<bool>,
110
111    /// send notification if Hue light changes
112    #[serde(skip_serializing_if = "Option::is_none")]
113    #[serde(default = "none_function")]
114    pub hue: Option<bool>,
115
116    /// send notification for macro
117    #[serde(skip_serializing_if = "Option::is_none")]
118    #[serde(default = "none_function")]
119    #[serde(rename = "macro")]
120    pub macro_field: Option<bool>,
121
122    /// sync groups this instance syncs (bit mapped)
123    #[serde(skip_serializing_if = "Option::is_none")]
124    #[serde(default = "none_function")]
125    pub grp: Option<u8>,
126
127    /// Number of times a UDP sync message is retransmitted. Increase to increase reliability
128    #[serde(skip_serializing_if = "Option::is_none")]
129    #[serde(default = "none_function")]
130    pub ret: Option<u8>,
131}
132
133#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
134#[serde(rename_all = "camelCase")]
135pub struct Nodes {
136    /// node List Enabled
137    #[serde(skip_serializing_if = "Option::is_none")]
138    #[serde(default = "none_function")]
139    pub list: Option<bool>,
140
141    /// node Broadcast Enabled
142    #[serde(skip_serializing_if = "Option::is_none")]
143    #[serde(default = "none_function")]
144    pub bcast: Option<bool>,
145}
146
147#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
148#[serde(rename_all = "camelCase")]
149pub struct Live {
150    /// receive UDP realtime
151    #[serde(skip_serializing_if = "Option::is_none")]
152    #[serde(default = "none_function")]
153    pub en: Option<bool>,
154
155    /// use Main Segment Only
156    #[serde(skip_serializing_if = "Option::is_none")]
157    #[serde(default = "none_function")]
158    pub mso: Option<bool>,
159
160    /// DMX in port. E1.31 default is 5568, Art-Net is 6454
161    #[serde(skip_serializing_if = "Option::is_none")]
162    #[serde(default = "none_function")]
163    pub port: Option<u16>,
164
165    /// multicast or unicast; who the fuck knows which one is which
166    #[serde(skip_serializing_if = "Option::is_none")]
167    #[serde(default = "none_function")]
168    pub mc: Option<bool>,
169
170    /// DMX info
171    #[serde(skip_serializing_if = "Option::is_none")]
172    #[serde(default = "none_function")]
173    pub dmx: Option<LiveDmx>,
174
175    /// (ms timeout of realtime mode before returning to normal mode) / 100
176    #[serde(skip_serializing_if = "Option::is_none")]
177    #[serde(default = "none_function")]
178    pub timeout: Option<u16>,
179
180    /// enable to force max brightness if source has very dark colors that would be black
181    #[serde(skip_serializing_if = "Option::is_none")]
182    #[serde(default = "none_function")]
183    pub maxbri: Option<bool>,
184
185    /// Disable gamma correction; activate if gamma correction is handled by the source
186    #[serde(skip_serializing_if = "Option::is_none")]
187    #[serde(default = "none_function")]
188    #[serde(rename = "no-gc")]
189    pub no_gc: Option<bool>,
190
191    /// realtime LED offset
192    #[serde(skip_serializing_if = "Option::is_none")]
193    #[serde(default = "none_function")]
194    pub offset: Option<u32>,
195}
196
197
198/// Dmx setting found in 'cfg. ...live.dmx', not the root 'cfg.dmx'
199#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
200#[serde(rename_all = "camelCase")]
201pub struct LiveDmx {
202    /// settings for E1.31 (sACN) protocol (only DMX_MODE_MULTIPLE_* can span over consecutive universes)
203    #[serde(skip_serializing_if = "Option::is_none")]
204    #[serde(default = "none_function")]
205    pub uni: Option<u16>,
206
207    /// freeze instead of flickering
208    #[serde(skip_serializing_if = "Option::is_none")]
209    #[serde(default = "none_function")]
210    pub seqskip: Option<bool>,
211
212    /// E1.31 port priority (if != 0 priority handling is active)
213    #[serde(skip_serializing_if = "Option::is_none")]
214    #[serde(default = "none_function")]
215    pub e131prio: Option<u8>,
216
217    /// DMX start address of fixture, a.k.a. first Channel [for E1.31 (sACN) protocol]
218    #[serde(skip_serializing_if = "Option::is_none")]
219    #[serde(default = "none_function")]
220    pub addr: Option<u16>,
221
222    /// DMX channel spacing; Number of void/unused channels between each segments DMX channels
223    #[serde(skip_serializing_if = "Option::is_none")]
224    #[serde(default = "none_function")]
225    pub dss: Option<u16>,
226
227    /// DMX mode
228    #[serde(skip_serializing_if = "Option::is_none")]
229    #[serde(default = "none_function")]
230    pub mode: Option<DmxMode>,
231}
232
233#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
234#[serde(rename_all = "camelCase")]
235pub struct Va {
236    /// enable device discovery by Amazon Echo
237    #[serde(skip_serializing_if = "Option::is_none")]
238    #[serde(default = "none_function")]
239    pub alexa: Option<bool>,
240
241    /// [macroAlexaOn, macroAlexaOff]
242    #[serde(skip_serializing_if = "Option::is_none")]
243    #[serde(default = "none_function")]
244    pub macros: Option<[u8; 2]>,
245
246    /// number of presets to expose to Alexa, starting from preset 1, up to 9
247    #[serde(skip_serializing_if = "Option::is_none")]
248    #[serde(default = "none_function")]
249    pub p: Option<u8>,
250}
251
252#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
253#[serde(rename_all = "camelCase")]
254pub struct Mqtt {
255    /// MQTT enabled?
256    #[serde(skip_serializing_if = "Option::is_none")]
257    #[serde(default = "none_function")]
258    pub en: Option<bool>,
259
260    /// both domains and IPs should work (no SSL)
261    #[serde(skip_serializing_if = "Option::is_none")]
262    #[serde(default = "none_function")]
263    pub broker: Option<String>,
264
265    /// MQTT port
266    #[serde(skip_serializing_if = "Option::is_none")]
267    #[serde(default = "none_function")]
268    pub port: Option<u16>,
269
270    /// optional: username for MQTT auth
271    #[serde(skip_serializing_if = "Option::is_none")]
272    #[serde(default = "none_function")]
273    pub user: Option<String>,
274
275    /// optional: length of password for MQTT auth
276    #[serde(skip_serializing_if = "Option::is_none")]
277    #[serde(default = "none_function")]
278    pub pskl: Option<u8>,
279
280    /// override the client ID
281    #[serde(skip_serializing_if = "Option::is_none")]
282    #[serde(default = "none_function")]
283    pub cid: Option<String>,
284
285    /// retain brightness and color
286    #[serde(skip_serializing_if = "Option::is_none")]
287    #[serde(default = "none_function")]
288    pub rtn: Option<bool>,
289
290    /// mqtt topics
291    #[serde(skip_serializing_if = "Option::is_none")]
292    #[serde(default = "none_function")]
293    pub topics: Option<Topics>,
294}
295
296#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
297#[serde(rename_all = "camelCase")]
298pub struct Topics {
299    /// main MQTT topic (individual per device, default is wled/mac)
300    #[serde(skip_serializing_if = "Option::is_none")]
301    #[serde(default = "none_function")]
302    pub device: Option<String>,
303
304    /// second MQTT topic (for example to group devices)
305    #[serde(skip_serializing_if = "Option::is_none")]
306    #[serde(default = "none_function")]
307    pub group: Option<String>,
308}
309
310#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
311#[serde(rename_all = "camelCase")]
312pub struct Hue {
313    /// poll hue bridge for light state
314    #[serde(skip_serializing_if = "Option::is_none")]
315    #[serde(default = "none_function")]
316    pub en: Option<bool>,
317
318    /// ID of hue lamp to sync to. Find the ID in the hue app ("about" section)
319    #[serde(skip_serializing_if = "Option::is_none")]
320    #[serde(default = "none_function")]
321    pub id: Option<u8>,
322
323    /// (low values (< 1sec) may cause lag but offer quicker response) / 100
324    #[serde(skip_serializing_if = "Option::is_none")]
325    #[serde(default = "none_function")]
326    pub iv: Option<u16>,
327
328    /// hue receiver info
329    #[serde(skip_serializing_if = "Option::is_none")]
330    #[serde(default = "none_function")]
331    pub recv: Option<Recv2>,
332
333    /// hue IP
334    #[serde(skip_serializing_if = "Option::is_none")]
335    #[serde(default = "none_function")]
336    pub ip: Option<[u8; 4]>,
337}
338
339#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
340#[serde(rename_all = "camelCase")]
341pub struct Recv2 {
342    /// hue Apply On Off
343    #[serde(skip_serializing_if = "Option::is_none")]
344    #[serde(default = "none_function")]
345    pub on: Option<bool>,
346
347    /// hue Apply Bri
348    #[serde(skip_serializing_if = "Option::is_none")]
349    #[serde(default = "none_function")]
350    pub bri: Option<bool>,
351
352    /// hue Apply Color
353    #[serde(skip_serializing_if = "Option::is_none")]
354    #[serde(default = "none_function")]
355    pub col: Option<bool>,
356}
357
358#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
359#[serde(rename_all = "camelCase")]
360pub struct Ntp {
361    /// get internet time. Only required if you use clock overlays or time-activated macros
362    #[serde(skip_serializing_if = "Option::is_none")]
363    #[serde(default = "none_function")]
364    pub en: Option<bool>,
365
366    /// NTP server to use
367    #[serde(skip_serializing_if = "Option::is_none")]
368    #[serde(default = "none_function")]
369    pub host: Option<String>,
370
371    /// Timezone ID. Refer to timezones array in wled10_ntp.ino
372    #[serde(skip_serializing_if = "Option::is_none")]
373    #[serde(default = "none_function")]
374    pub tz: Option<TimeZoneId>,
375
376    /// Seconds to offset from UTC before timzone calculation
377    #[serde(skip_serializing_if = "Option::is_none")]
378    #[serde(default = "none_function")]
379    pub offset: Option<u32>,
380
381    /// Use AM/PM;  12h/24h clock format
382    #[serde(skip_serializing_if = "Option::is_none")]
383    #[serde(default = "none_function")]
384    pub ampm: Option<bool>,
385
386    /// longitude
387    #[serde(skip_serializing_if = "Option::is_none")]
388    #[serde(default = "none_function")]
389    pub ln: Option<f64>,
390
391    /// latitude
392    #[serde(skip_serializing_if = "Option::is_none")]
393    #[serde(default = "none_function")]
394    pub lt: Option<f64>,
395}
396
397
398/// DMX modes
399#[allow(non_camel_case_types)]
400#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
401#[repr(u8)]
402pub enum DmxMode {
403    /// Not used
404    DMX_MODE_DISABLED = 0,
405    /// all LEDs same RGB color (3 channels)
406    DMX_MODE_SINGLE_RGB = 1,
407    /// all LEDs same RGB color and master dimmer (4 channels)
408    DMX_MODE_SINGLE_DRGB = 2,
409    /// trigger standalone effects of WLED (15 channels)
410    DMX_MODE_EFFECT = 3,
411    /// trigger standalone effects of WLED (18 channels)
412    DMX_MODE_EFFECT_W = 7,
413    /// every LED is addressed with its own RGB (ledCount * 3 channels)
414    DMX_MODE_MULTIPLE_RGB = 4,
415    /// every LED is addressed with its own RGB and share a master dimmer (ledCount * 3 + 1 channels)
416    DMX_MODE_MULTIPLE_DRGB = 5,
417    /// every LED is addressed with its own RGBW (ledCount * 4 channels)
418    DMX_MODE_MULTIPLE_RGBW = 6,
419    /// trigger standalone effects of WLED (15 channels per segment)
420    DMX_MODE_EFFECT_SEGMENT = 8,
421    /// trigger standalone effects of WLED (18 channels per segment)
422    DMX_MODE_EFFECT_SEGMENT_W = 9,
423    /// apply presets (1 channel)
424    DMX_MODE_PRESET = 10,
425    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
426    RSVD1,
427    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
428    RSVD2,
429    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
430    RSVD3,
431    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
432    RSVD4,
433    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
434    RSVD5,
435    /// Reserved to keep some semblance of backwards compatibility when new WLED versions come out with more Night Light modes
436    RSVD6,
437
438}
439
440/// Time zone IDs
441#[allow(non_camel_case_types)]
442#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
443#[repr(u8)]
444pub enum TimeZoneId {
445    TZ_UTC,
446    TZ_UK,
447    TZ_EUROPE_CENTRAL,
448    TZ_EUROPE_EASTERN,
449    TZ_US_EASTERN,
450    TZ_US_CENTRAL,
451    TZ_US_MOUNTAIN,
452    TZ_US_ARIZONA,
453    TZ_US_PACIFIC,
454    TZ_CHINA,
455    TZ_JAPAN,
456    TZ_AUSTRALIA_EASTERN,
457    TZ_NEW_ZEALAND,
458    TZ_NORTH_KOREA,
459    TZ_INDIA,
460    TZ_SASKACHEWAN,
461    TZ_AUSTRALIA_NORTHERN,
462    TZ_AUSTRALIA_SOUTHERN,
463    TZ_HAWAII,
464    TZ_NOVOSIBIRSK,
465    TZ_ANCHORAGE,
466    TZ_MX_CENTRAL,
467    TZ_PAKISTAN,
468    TZ_RSVD1,
469    TZ_RSVD2,
470    TZ_RSVD3,
471    TZ_RSVD4,
472    TZ_RSVD5,
473    TZ_RSVD6,
474    TZ_INIT = 255
475}