6#include <soc/soc_caps.h>
10#error "This library requires Zigbee support to be enabled in sdkconfig"
14#include <ha/esp_zigbee_ha_standard.h>
15#include <Preferences.h>
24#ifndef PILOT_WIRE_MANUF_NAME
25#define PILOT_WIRE_MANUF_NAME "EpsilonRT"
35#ifndef PILOT_WIRE_MODEL_NAME
36#define PILOT_WIRE_MODEL_NAME "ERT-MPZ-03"
47#ifndef PILOT_WIRE_MANUF_CODE
48#define PILOT_WIRE_MANUF_CODE 0x1234
55#define PILOT_WIRE_CLUSTER_ID 0xFC00
60#define PILOT_WIRE_MODE_ATTR_ID 0x0000
66enum ZigbeePilotWireMode : uint8_t {
67 PILOTWIRE_MODE_OFF = 0,
68 PILOTWIRE_MODE_COMFORT,
70 PILOTWIRE_MODE_FROST_PROTECTION,
71 PILOTWIRE_MODE_COMFORT_MINUS_1,
72 PILOTWIRE_MODE_COMFORT_MINUS_2
79const ZigbeePilotWireMode PILOTWIRE_MODE_MIN = PILOTWIRE_MODE_OFF;
85const ZigbeePilotWireMode PILOTWIRE_MODE_MAX = PILOTWIRE_MODE_COMFORT_MINUS_2;
91const uint8_t PILOTWIRE_MODE_COUNT = (PILOTWIRE_MODE_COMFORT_MINUS_2 - PILOTWIRE_MODE_OFF + 1);
176 bool begin (
float currentTemperature);
188 bool begin (int32_t currentPower, uint32_t meteringMultiplier = 0);
202 bool begin (
float currentTemperature, int32_t currentPower, uint32_t meteringMultiplier = 0);
383 _prefs.putBool (
"restore", enable);
418 void zbAttributeSet (
const esp_zb_zcl_set_attr_value_message_t *message)
override;
420 uint16_t min_interval, uint16_t max_interval,
float delta,
421 uint16_t manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC);
422 bool reportAttribute (uint16_t cluster_id, uint16_t attr_id, uint16_t manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC);
Class representing a Zigbee Pilot Wire Control endpoint. This class extends the ZigbeeEP class to imp...
float temperatureMax() const
Get the maximum temperature value.
bool setTemperature(float value)
Set the temperature value for the temperature measurement cluster.
bool setPowerW(int32_t demand_w)
Set the electric power attribute in the metering cluster.
ZigbeePilotWireControl(uint8_t endpoint, float tempMin, float tempMax, uint32_t meteringMultiplier)
Constructor for ZigbeePilotWireControl with temperature measurement and metering. This constructor en...
void printClusterInfo(Print &out=Serial)
Print the cluster information of the ZigbeePilotWireControl endpoint. This method outputs the cluster...
void(* _on_mode_change)(ZigbeePilotWireMode mode)
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 reportEnergyWh()
Report the current summation delivered value to the Zigbee network. The reporting is configured via s...
bool powerState() const
Get the current power state.
void zbAttributeSet(const esp_zb_zcl_set_attr_value_message_t *message) override
void enableNvs(bool enable)
Enable or disable restore mode. When restore mode is enabled, the Pilot Wire mode is restored from NV...
bool begin()
Initialize the ZigbeePilotWireControl endpoint and create clusters. This method sets up the necessary...
uint64_t energyWh() const
Get the current summation delivered value.
ZigbeePilotWireControl(uint8_t endpoint)
Constructor for ZigbeePilotWireControl.
~ZigbeePilotWireControl()
Destructor for ZigbeePilotWireControl. Cleans up resources and ends NVS preferences.
esp_zb_int24_t _instantaneousDemand
esp_zb_uint24_t _multiplier
bool _temperature_enabled
bool reportAttribute(uint16_t cluster_id, uint16_t attr_id, uint16_t manuf_code=ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC)
bool reportPowerW()
Report the current electric power value to the Zigbee network. The reporting is configured via setPow...
bool begin(int32_t currentPower, uint32_t meteringMultiplier=0)
Initialize the ZigbeePilotWireControl endpoint with metering. This method sets up the necessary clust...
bool setPilotWireMode(ZigbeePilotWireMode mode)
Set the Pilot Wire mode. This method updates the Pilot Wire mode attribute and notifies the applicati...
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)
ZigbeePilotWireMode pilotWireMode() const
Get the current Pilot Wire mode.
int32_t powerW() const
Get the current electric power value.
bool setTemperatureReporting(uint16_t min_interval, uint16_t max_interval, float delta)
Set the reporting interval for the temperature measurement cluster.
esp_zb_uint48_t _summationDelivered
bool reportAttributes()
Report the current attributes to the Zigbee network. This method updates the Pilot Wire mode,...
bool _current_state_changed
uint8_t meteringStatus() const
Get the current metering status value.
bool reportTemperature()
Report the current temperature value to the Zigbee network. The reporting is configured via setTemper...
bool begin(float currentTemperature, int32_t currentPower, uint32_t meteringMultiplier=0)
Initialize the ZigbeePilotWireControl endpoint with temperature measurement and metering....
bool begin(float currentTemperature)
Initialize the ZigbeePilotWireControl endpoint with temperature measurement. This method sets up the ...
bool createTemperatureMeasurementCluster(float currentTemperature)
float temperature() const
Get the current temperature value.
bool reportPilotModeAndOnOff()
Report the current Pilot Wire mode and On/Off attributes to the Zigbee network. This method call the ...
esp_zb_temperature_meas_cluster_cfg_t _temperature_cfg
bool setEnergyWh(uint64_t summation_wh)
Set the summation delivered attribute in the metering cluster.
float temperatureMin() const
Get the minimum temperature value.
bool createMeteringCluster(int32_t currentPower, uint32_t meteringMultiplier)
ZigbeePilotWireControl(uint8_t endpoint, uint32_t meteringMultiplier)
Constructor for ZigbeePilotWireControl with metering. This constructor enables the metering cluster....
void onPilotWireModeChange(void(*callback)(ZigbeePilotWireMode mode))
Set a callback function to be called when the Pilot Wire mode changes. This function must be called t...
esp_zb_metering_cluster_cfg_t _metering_cfg
void pilotWireModeChanged()
void end()
End the ZigbeePilotWireControl and clean up resources. This method should be called to properly relea...
bool createPilotWireCluster()
bool isNvsEnabled() const
Check if restore mode is enabled.
bool setMeteringStatus(uint8_t status)
Set the metering status attribute in the metering cluster.
ZigbeePilotWireControl(uint8_t endpoint, float tempMin, float tempMax)
Constructor for ZigbeePilotWireControl with temperature measurement. This constructor enables the tem...
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.