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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// SPDX-License-Identifier: MPL-2.0
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Tasmota command definitions.
//!
//! This module provides typed representations of Tasmota commands that can be
//! sent via HTTP or MQTT protocols.
//!
//! # Available Commands
//!
//! | Command Type | Purpose | Example |
//! |-------------|---------|---------|
//! | [`PowerCommand`] | Control relay power state | On, Off, Toggle |
//! | [`DimmerCommand`] | Adjust brightness (0-100) | Set to 75% |
//! | [`ColorTemperatureCommand`] | Set white color temperature | Warm, Cool |
//! | [`HsbColorCommand`] | Set RGB color in HSB format | Red, Blue |
//! | [`SchemeCommand`] | Set light scheme/effect (0-4) | Wakeup, Random |
//! | [`WakeupDurationCommand`] | Set wakeup duration (1-3000s) | 5 minutes |
//! | [`FadeDurationCommand`] | Set fade transition duration (0.5-20s) | 2s, 10s |
//! | [`FadeCommand`] | Enable/disable fade transitions | On, Off |
//! | [`EnergyCommand`] | Query energy consumption | Get, Reset |
//! | [`StatusCommand`] | Query device status | Status 0-10 |
//!
//! # Command Structure
//!
//! Each Tasmota command consists of:
//! - A command name (e.g., "Power", "Dimmer", "Status")
//! - An optional index suffix (e.g., "Power1", "Power2")
//! - An optional payload (e.g., "ON", "50", "120,100,75")
//!
//! # Examples
//!
//! ## Basic power control
//!
//! ```
//! use tasmor_lib::command::{Command, PowerCommand};
//! use tasmor_lib::types::{PowerIndex, PowerState};
//!
//! let cmd = PowerCommand::Set {
//! index: PowerIndex::one(),
//! state: PowerState::On,
//! };
//!
//! assert_eq!(cmd.name(), "Power1");
//! assert_eq!(cmd.payload(), Some("ON".to_string()));
//! ```
//!
//! ## Light control
//!
//! ```
//! use tasmor_lib::command::{Command, DimmerCommand, ColorTemperatureCommand};
//! use tasmor_lib::types::{Dimmer, ColorTemperature};
//!
//! // Set brightness to 75%
//! let dim = DimmerCommand::Set(Dimmer::new(75).unwrap());
//! assert_eq!(dim.payload(), Some("75".to_string()));
//!
//! // Set warm white color temperature
//! let ct = ColorTemperatureCommand::Set(ColorTemperature::WARM);
//! assert_eq!(ct.name(), "CT");
//! ```
pub use EnergyCommand;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
use crateResponseSpec;
/// A command that can be sent to a Tasmota device.
///
/// Commands are serialized to the Tasmota command format for transmission
/// over HTTP or MQTT.