|
ZigbeePilotWireControl Library
Zigbee Pilot Wire Control Library
|
Class representing a Zigbee Pilot Wire Control endpoint. This class extends the ZigbeeEP class to implement a custom cluster for controlling pilot-wire electric heaters via Zigbee. More...
#include <ZigbeePilotWireControl.h>
Public Member Functions | |
| ZigbeePilotWireControl (uint8_t endpoint) | |
| Constructor for ZigbeePilotWireControl. | |
| ZigbeePilotWireControl (uint8_t endpoint, float tempMin, float tempMax) | |
| Constructor for ZigbeePilotWireControl with temperature measurement. This constructor enables the temperature measurement cluster. The metering cluster is disabled. You must call begin(float currentTemperature) after constructing the object to initialize the endpoint. | |
| ZigbeePilotWireControl (uint8_t endpoint, uint32_t meteringMultiplier) | |
| Constructor for ZigbeePilotWireControl with metering. This constructor enables the metering cluster. The temperature measurement cluster is disabled. You must call begin() after constructing the object to initialize the endpoint. | |
| ZigbeePilotWireControl (uint8_t endpoint, float tempMin, float tempMax, uint32_t meteringMultiplier) | |
| Constructor for ZigbeePilotWireControl with temperature measurement and metering. This constructor enables both the temperature measurement and metering clusters. You must call begin(float currentTemperature) after constructing the object to initialize the endpoint. | |
| void | onPilotWireModeChange (void(*callback)(ZigbeePilotWireMode mode)) |
| Set a callback function to be called when the Pilot Wire mode changes. This function must be called to register a callback that will be invoked before to call begin(). | |
| bool | begin () |
| Initialize the ZigbeePilotWireControl endpoint and create clusters. This method sets up the necessary clusters for Pilot Wire Control, including On/Off, Pilot Wire mode and adds the endpoint to the Zigbee stack. | |
| bool | begin (float currentTemperature) |
| Initialize the ZigbeePilotWireControl endpoint with temperature measurement. This method sets up the necessary clusters for Pilot Wire Control, including On/Off, Pilot Wire mode, Temperature Measurement and adds the endpoint to the Zigbee stack. | |
| bool | begin (int32_t currentPower, uint32_t meteringMultiplier=0) |
| Initialize the ZigbeePilotWireControl endpoint with metering. This method sets up the necessary clusters for Pilot Wire Control, including On/Off, Pilot Wire mode, Metering and adds the endpoint to the Zigbee stack. | |
| bool | begin (float currentTemperature, int32_t currentPower, uint32_t meteringMultiplier=0) |
| Initialize the ZigbeePilotWireControl endpoint with temperature measurement and metering. This method sets up the necessary clusters for Pilot Wire Control, including On/Off, Pilot Wire mode, Temperature Measurement, Metering and adds the endpoint to the Zigbee stack. | |
| ZigbeePilotWireMode | pilotWireMode () const |
| Get the current Pilot Wire mode. | |
| bool | powerState () const |
| Get the current power state. | |
| bool | setPilotWireMode (ZigbeePilotWireMode mode) |
| Set the Pilot Wire mode. This method updates the Pilot Wire mode attribute and notifies the application of the mode change via the registered callback function. | |
| bool | reportPilotModeAndOnOff () |
| Report the current Pilot Wire mode and On/Off attributes to the Zigbee network. This method call the callback to notify the application of the current mode, and updates the Pilot Wire mode and On/Off attributes in the Zigbee stack. | |
| bool | setTemperature (float value) |
| Set the temperature value for the temperature measurement cluster. | |
| float | temperature () const |
| Get the current temperature value. | |
| float | temperatureMin () const |
| Get the minimum temperature value. | |
| float | temperatureMax () const |
| Get the maximum temperature value. | |
| bool | setTemperatureReporting (uint16_t min_interval, uint16_t max_interval, float delta) |
| Set the reporting interval for the temperature measurement cluster. | |
| bool | reportTemperature () |
| Report the current temperature value to the Zigbee network. The reporting is configured via setTemperatureReporting(), so this method can be used to force a report outside of the configured intervals. | |
| bool | setEnergyWh (uint64_t summation_wh) |
| Set the summation delivered attribute in the metering cluster. | |
| uint64_t | energyWh () const |
| Get the current summation delivered value. | |
| bool | reportEnergyWh () |
| Report the current summation delivered value to the Zigbee network. The reporting is configured via setEnergyWhReporting(), so this method can be used to force a report outside of the configured intervals. | |
| bool | setEnergyWhReporting (uint16_t min_interval, uint16_t max_interval, float delta) |
| Set the reporting interval for the summation delivered attribute in the metering cluster. | |
| bool | setPowerW (int32_t demand_w) |
| Set the electric power attribute in the metering cluster. | |
| int32_t | powerW () const |
| Get the current electric power value. | |
| bool | reportPowerW () |
| Report the current electric power value to the Zigbee network. The reporting is configured via setPowerWReporting(), so this method can be used to force a report outside of the configured intervals. | |
| bool | setPowerWReporting (uint16_t min_interval, uint16_t max_interval, float delta) |
| Set the reporting interval for the electric power attribute in the metering cluster. | |
| bool | setMeteringStatus (uint8_t status) |
| Set the metering status attribute in the metering cluster. | |
| uint8_t | meteringStatus () const |
| Get the current metering status value. | |
| bool | reportAttributes () |
| Report the current attributes to the Zigbee network. This method updates the Pilot Wire mode, On/Off, temperature (if enabled) and metering (if enabled) attributes in the Zigbee stack. | |
| void | enableNvs (bool enable) |
| Enable or disable restore mode. When restore mode is enabled, the Pilot Wire mode is restored from NVS on startup. | |
| bool | isNvsEnabled () const |
| Check if restore mode is enabled. | |
| ~ZigbeePilotWireControl () | |
| Destructor for ZigbeePilotWireControl. Cleans up resources and ends NVS preferences. | |
| void | end () |
| End the ZigbeePilotWireControl and clean up resources. This method should be called to properly release resources used by the ZigbeePilotWireControl instance. | |
| void | printClusterInfo (Print &out=Serial) |
| Print the cluster information of the ZigbeePilotWireControl endpoint. This method outputs the cluster details to the specified Print object for debugging purposes. | |
Protected Member Functions | |
| void | zbAttributeSet (const esp_zb_zcl_set_attr_value_message_t *message) override |
| bool | setReporting (uint16_t cluster_id, uint16_t attr_id, uint16_t min_interval, uint16_t max_interval, float delta, uint16_t manuf_code=ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC) |
| bool | reportAttribute (uint16_t cluster_id, uint16_t attr_id, uint16_t manuf_code=ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC) |
| bool | createPilotWireCluster () |
| bool | createTemperatureMeasurementCluster (float currentTemperature) |
| bool | createMeteringCluster (int32_t currentPower, uint32_t meteringMultiplier) |
Private Member Functions | |
| void | pilotWireModeChanged () |
Private Attributes | |
| uint8_t | _current_mode |
| uint8_t | _state_on_mode |
| void(* | _on_mode_change )(ZigbeePilotWireMode mode) |
| bool | _current_state |
| bool | _current_state_changed |
| bool | _nvs_enabled |
| Preferences | _prefs |
| bool | _temperature_enabled |
| esp_zb_temperature_meas_cluster_cfg_t | _temperature_cfg |
| float | _temperature_value |
| bool | _metering_enabled |
| esp_zb_metering_cluster_cfg_t | _metering_cfg |
| esp_zb_uint48_t | _summationDelivered |
| esp_zb_uint24_t | _multiplier |
| esp_zb_uint24_t | _divisor |
| esp_zb_int24_t | _instantaneousDemand |
Class representing a Zigbee Pilot Wire Control endpoint. This class extends the ZigbeeEP class to implement a custom cluster for controlling pilot-wire electric heaters via Zigbee.
Definition at line 98 of file ZigbeePilotWireControl.h.
| ZigbeePilotWireControl::ZigbeePilotWireControl | ( | uint8_t | endpoint | ) |
Constructor for ZigbeePilotWireControl.
Temperature measurement and metering clusters are disabled. You must call begin() after constructing the object to initialize the endpoint.
| endpoint | The Zigbee endpoint number to use for this device. |
| ZigbeePilotWireControl::ZigbeePilotWireControl | ( | uint8_t | endpoint, |
| float | tempMin, | ||
| float | tempMax | ||
| ) |
Constructor for ZigbeePilotWireControl with temperature measurement. This constructor enables the temperature measurement cluster. The metering cluster is disabled. You must call begin(float currentTemperature) after constructing the object to initialize the endpoint.
| endpoint | The Zigbee endpoint number to use for this device. |
| tempMin | The minimum temperature value for the temperature measurement cluster in degrees Celsius. |
| tempMax | The maximum temperature value for the temperature measurement cluster in degrees Celsius. |
| ZigbeePilotWireControl::ZigbeePilotWireControl | ( | uint8_t | endpoint, |
| uint32_t | meteringMultiplier | ||
| ) |
Constructor for ZigbeePilotWireControl with metering. This constructor enables the metering cluster. The temperature measurement cluster is disabled. You must call begin() after constructing the object to initialize the endpoint.
| endpoint | The Zigbee endpoint number to use for this device. |
| meteringMultiplier | The multiplier value for the metering cluster, must be non-zero to enable metering. This value must be updated whis begin(uint32_t meteringMultiplier). |
| ZigbeePilotWireControl::ZigbeePilotWireControl | ( | uint8_t | endpoint, |
| float | tempMin, | ||
| float | tempMax, | ||
| uint32_t | meteringMultiplier | ||
| ) |
Constructor for ZigbeePilotWireControl with temperature measurement and metering. This constructor enables both the temperature measurement and metering clusters. You must call begin(float currentTemperature) after constructing the object to initialize the endpoint.
| endpoint | The Zigbee endpoint number to use for this device. |
| tempMin | The minimum temperature value for the temperature measurement cluster in degrees Celsius. |
| tempMax | The maximum temperature value for the temperature measurement cluster in degrees Celsius. |
| meteringMultiplier | The multiplier value for the metering cluster, must be non-zero to enable metering. This value must be updated whis begin(float currentTemperature, uint32_t meteringMultiplier). |
|
inline |
Destructor for ZigbeePilotWireControl. Cleans up resources and ends NVS preferences.
Definition at line 398 of file ZigbeePilotWireControl.h.
References end().
| bool ZigbeePilotWireControl::begin | ( | ) |
Initialize the ZigbeePilotWireControl endpoint and create clusters. This method sets up the necessary clusters for Pilot Wire Control, including On/Off, Pilot Wire mode and adds the endpoint to the Zigbee stack.
| bool ZigbeePilotWireControl::begin | ( | float | currentTemperature | ) |
Initialize the ZigbeePilotWireControl endpoint with temperature measurement. This method sets up the necessary clusters for Pilot Wire Control, including On/Off, Pilot Wire mode, Temperature Measurement and adds the endpoint to the Zigbee stack.
| currentTemperature | The initial temperature value for the temperature measurement cluster in degrees Celsius. |
| bool ZigbeePilotWireControl::begin | ( | float | currentTemperature, |
| int32_t | currentPower, | ||
| uint32_t | meteringMultiplier = 0 |
||
| ) |
Initialize the ZigbeePilotWireControl endpoint with temperature measurement and metering. This method sets up the necessary clusters for Pilot Wire Control, including On/Off, Pilot Wire mode, Temperature Measurement, Metering and adds the endpoint to the Zigbee stack.
| currentTemperature | The initial temperature value for the temperature measurement cluster in degrees Celsius. |
| currentPower | The initial instantaneous power demand value for the metering cluster in watts (W). |
| meteringMultiplier | The multiplier value for the metering cluster, this value was set in the constructor. If meteringMultiplier is zero, no change is made to the value set in the constructor. |
| bool ZigbeePilotWireControl::begin | ( | int32_t | currentPower, |
| uint32_t | meteringMultiplier = 0 |
||
| ) |
Initialize the ZigbeePilotWireControl endpoint with metering. This method sets up the necessary clusters for Pilot Wire Control, including On/Off, Pilot Wire mode, Metering and adds the endpoint to the Zigbee stack.
| currentPower | The initial instantaneous power demand value for the metering cluster in watts (W). |
| meteringMultiplier | The multiplier value for the metering cluster, this value was set in the constructor. If meteringMultiplier is zero, no change is made to the value set in the constructor. |
|
protected |
|
protected |
|
protected |
|
inline |
Enable or disable restore mode. When restore mode is enabled, the Pilot Wire mode is restored from NVS on startup.
| enable | true to enable restore mode, false to disable. |
Definition at line 381 of file ZigbeePilotWireControl.h.
References _nvs_enabled, and _prefs.
|
inline |
End the ZigbeePilotWireControl and clean up resources. This method should be called to properly release resources used by the ZigbeePilotWireControl instance.
Definition at line 406 of file ZigbeePilotWireControl.h.
References _prefs.
Referenced by ~ZigbeePilotWireControl().
| uint64_t ZigbeePilotWireControl::energyWh | ( | ) | const |
Get the current summation delivered value.
|
inline |
Check if restore mode is enabled.
Definition at line 390 of file ZigbeePilotWireControl.h.
References _nvs_enabled.
|
inline |
Get the current metering status value.
Definition at line 363 of file ZigbeePilotWireControl.h.
References _metering_cfg.
|
inline |
Set a callback function to be called when the Pilot Wire mode changes. This function must be called to register a callback that will be invoked before to call begin().
| callback | A function pointer to the callback function. The callback function should have the following signature: void callback(ZigbeePilotWireMode mode); The mode parameter will contain the new Pilot Wire mode. This function is used to notify the application of mode changes. |
Definition at line 155 of file ZigbeePilotWireControl.h.
References _on_mode_change.
|
inline |
Get the current Pilot Wire mode.
Definition at line 208 of file ZigbeePilotWireControl.h.
References _current_mode.
|
private |
|
inline |
Get the current power state.
Definition at line 216 of file ZigbeePilotWireControl.h.
References _current_state.
| int32_t ZigbeePilotWireControl::powerW | ( | ) | const |
Get the current electric power value.
| void ZigbeePilotWireControl::printClusterInfo | ( | Print & | out = Serial | ) |
Print the cluster information of the ZigbeePilotWireControl endpoint. This method outputs the cluster details to the specified Print object for debugging purposes.
| out | The Print object to output the cluster information to. Defaults to Serial. |
|
protected |
| bool ZigbeePilotWireControl::reportAttributes | ( | ) |
Report the current attributes to the Zigbee network. This method updates the Pilot Wire mode, On/Off, temperature (if enabled) and metering (if enabled) attributes in the Zigbee stack.
| bool ZigbeePilotWireControl::reportEnergyWh | ( | ) |
Report the current summation delivered value to the Zigbee network. The reporting is configured via setEnergyWhReporting(), so this method can be used to force a report outside of the configured intervals.
| bool ZigbeePilotWireControl::reportPilotModeAndOnOff | ( | ) |
Report the current Pilot Wire mode and On/Off attributes to the Zigbee network. This method call the callback to notify the application of the current mode, and updates the Pilot Wire mode and On/Off attributes in the Zigbee stack.
| bool ZigbeePilotWireControl::reportPowerW | ( | ) |
Report the current electric power value to the Zigbee network. The reporting is configured via setPowerWReporting(), so this method can be used to force a report outside of the configured intervals.
| bool ZigbeePilotWireControl::reportTemperature | ( | ) |
Report the current temperature value to the Zigbee network. The reporting is configured via setTemperatureReporting(), so this method can be used to force a report outside of the configured intervals.
| bool ZigbeePilotWireControl::setEnergyWh | ( | uint64_t | summation_wh | ) |
Set the summation delivered attribute in the metering cluster.
| summation_wh | The total energy delivered in watt-hours (Wh). uint48_t value. if isNvsEnabled() is true, this value is stored in NVS and restored on startup. |
| bool ZigbeePilotWireControl::setEnergyWhReporting | ( | uint16_t | min_interval, |
| uint16_t | max_interval, | ||
| float | delta | ||
| ) |
Set the reporting interval for the summation delivered attribute in the metering cluster.
| min_interval | The minimum reporting interval in seconds. This is the shortest time between reports even if the energy changes. |
| max_interval | The maximum reporting interval in seconds. This is the longest time between reports even if the energy does not change. |
| delta | The energy change delta in watt-hours (Wh). This is the minimum change in energy that triggers a report. |
| bool ZigbeePilotWireControl::setMeteringStatus | ( | uint8_t | status | ) |
Set the metering status attribute in the metering cluster.
| status | The metering status (bitmap U8 in ZCL). bit 6 Service Disconnect Open: Set to true when the service have been disconnected to this premises. bit 5 Leak Detect: Set to true when a leak has been detected. bit 4 Power Quality: Set to true if a power quality event has been detected such as a low voltage, high voltage. bit 3 Power Failure: Set to true during a power outage. bit 2 Tamper Detect: Set to true if a tamper event has been detected. bit 1 Low Battery: Set to true when the battery needs maintenance. bit 0 Check Meter: Set to true when a non fatal problem has been detected on the meter such as a measurement error, memory error, and self check error. |
| bool ZigbeePilotWireControl::setPilotWireMode | ( | ZigbeePilotWireMode | mode | ) |
Set the Pilot Wire mode. This method updates the Pilot Wire mode attribute and notifies the application of the mode change via the registered callback function.
| mode | The new Pilot Wire mode to set. |
| bool ZigbeePilotWireControl::setPowerW | ( | int32_t | demand_w | ) |
Set the electric power attribute in the metering cluster.
| demand_w | The instantaneous power demand in watts (W). uint24_t value representing -8388608 to 8388607 W. |
| bool ZigbeePilotWireControl::setPowerWReporting | ( | uint16_t | min_interval, |
| uint16_t | max_interval, | ||
| float | delta | ||
| ) |
Set the reporting interval for the electric power attribute in the metering cluster.
| min_interval | The minimum reporting interval in seconds. This is the shortest time between reports even if the power changes. |
| max_interval | The maximum reporting interval in seconds. This is the longest time between reports even if the power does not change. |
| delta | The power change delta in watts (W). This is the minimum change in power that triggers a report. |
|
protected |
| bool ZigbeePilotWireControl::setTemperature | ( | float | value | ) |
Set the temperature value for the temperature measurement cluster.
| temperature | The temperature value in degrees Celsius, the resolution is 0.01 degree. |
| bool ZigbeePilotWireControl::setTemperatureReporting | ( | uint16_t | min_interval, |
| uint16_t | max_interval, | ||
| float | delta | ||
| ) |
Set the reporting interval for the temperature measurement cluster.
| min_interval | The minimum reporting interval in seconds. This is the shortest time between reports even if the temperature changes. |
| max_interval | The maximum reporting interval in seconds. This is the longest time between reports even if the temperature does not change. |
| delta | The temperature change delta in degrees Celsius, the resolution is 0.01 degree. This is the minimum change in temperature that triggers a report. |
|
inline |
Get the current temperature value.
Definition at line 250 of file ZigbeePilotWireControl.h.
References _temperature_value.
| float ZigbeePilotWireControl::temperatureMax | ( | ) | const |
Get the maximum temperature value.
| float ZigbeePilotWireControl::temperatureMin | ( | ) | const |
Get the minimum temperature value.
|
overrideprotected |
|
private |
Definition at line 430 of file ZigbeePilotWireControl.h.
Referenced by pilotWireMode().
|
private |
Definition at line 434 of file ZigbeePilotWireControl.h.
Referenced by powerState().
|
private |
Definition at line 435 of file ZigbeePilotWireControl.h.
|
private |
Definition at line 448 of file ZigbeePilotWireControl.h.
|
private |
Definition at line 449 of file ZigbeePilotWireControl.h.
|
private |
Definition at line 445 of file ZigbeePilotWireControl.h.
Referenced by meteringStatus().
|
private |
Definition at line 444 of file ZigbeePilotWireControl.h.
|
private |
Definition at line 447 of file ZigbeePilotWireControl.h.
|
private |
Definition at line 436 of file ZigbeePilotWireControl.h.
Referenced by enableNvs(), and isNvsEnabled().
|
private |
Definition at line 432 of file ZigbeePilotWireControl.h.
Referenced by onPilotWireModeChange().
|
private |
Definition at line 437 of file ZigbeePilotWireControl.h.
Referenced by enableNvs(), and end().
|
private |
Definition at line 431 of file ZigbeePilotWireControl.h.
|
private |
Definition at line 446 of file ZigbeePilotWireControl.h.
|
private |
Definition at line 440 of file ZigbeePilotWireControl.h.
|
private |
Definition at line 439 of file ZigbeePilotWireControl.h.
|
private |
Definition at line 441 of file ZigbeePilotWireControl.h.
Referenced by temperature().