A full-featured thermostat with heating/cooling setpoints, weekly scheduling, and automatic mode switching. Temperature values are in 0.01°C units throughout.
#![allow(unused)]
fn main() {
use zigbee_zcl::clusters::thermostat::ThermostatCluster;
let mut therm = ThermostatCluster::new();
// Update temperature from sensor (22.50°C):
therm.set_local_temperature(2250);
// In the periodic callback — advance schedule and compute running mode:
// day_of_week: bitmask (bit 0 = Sunday .. bit 6 = Saturday)
// minutes_since_midnight: current time of day
therm.tick(0b0000010, 480); // Monday, 08:00
// SystemMode and setpoints can be written remotely via Write Attributes
// RunningMode is computed automatically by tick():
// - Auto mode: heats if temp < heat SP, cools if temp > cool SP
// - Heat mode: heats if temp < heat SP
// - Cool mode: cools if temp > cool SP
}
No cluster-specific commands — fan mode is set via Write Attributes.
#![allow(unused)]
fn main() {
use zigbee_zcl::clusters::fan_control::FanControlCluster;
let mut fan = FanControlCluster::new();
assert_eq!(fan.fan_mode(), 0x05); // Auto by default
fan.set_fan_mode(0x03); // High
}
#![allow(unused)]
fn main() {
use zigbee_zcl::clusters::thermostat::ThermostatCluster;
use zigbee_zcl::clusters::fan_control::FanControlCluster;
use zigbee_zcl::clusters::thermostat_ui::ThermostatUiCluster;
use zigbee_zcl::clusters::temperature::TemperatureCluster;
let mut therm = ThermostatCluster::new();
let mut fan = FanControlCluster::new();
let mut ui = ThermostatUiCluster::new();
let mut temp_sensor = TemperatureCluster::new(-1000, 5000);
// Periodic callback (every minute):
let reading = read_temperature_sensor(); // 0.01°C units
temp_sensor.set_temperature(reading);
therm.set_local_temperature(reading);
therm.tick(get_day_of_week(), get_minutes_since_midnight());
// The thermostat running mode drives the HVAC relays
}