Add water freeze device type

This commit is contained in:
Rohit Jadhav
2024-04-04 15:04:28 +05:30
parent 67de7b4f3a
commit 09d1ef4381
5 changed files with 62 additions and 1 deletions
+1
View File
@@ -55,6 +55,7 @@ g. Sensors
8. Smoke CO Alarm 8. Smoke CO Alarm
9. Water Leak Detector 9. Water Leak Detector
10. Rain Sensor 10. Rain Sensor
11. Water Freeze Detector
h. Robotic h. Robotic
1. Robotic Vacuum Cleaner 1. Robotic Vacuum Cleaner
@@ -1561,6 +1561,44 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
} }
} /* water_leak_detector */ } /* water_leak_detector */
namespace water_freeze_detector {
uint32_t get_device_type_id()
{
return ESP_MATTER_WATER_FREEZE_DETECTOR_DEVICE_TYPE_ID;
}
uint8_t get_device_type_version()
{
return ESP_MATTER_WATER_FREEZE_DETECTOR_DEVICE_TYPE_VERSION;
}
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data)
{
endpoint_t *endpoint = endpoint::create(node, flags, priv_data);
add(endpoint, config);
return endpoint;
}
esp_err_t add(endpoint_t *endpoint, config_t *config)
{
if (!endpoint) {
ESP_LOGE(TAG, "Endpoint cannot be NULL");
return ESP_ERR_INVALID_ARG;
}
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to add device type id:%" PRIu32 ",err: %d", get_device_type_id(), err);
return err;
}
descriptor::create(endpoint, &(config->descriptor), CLUSTER_FLAG_SERVER);
identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER);
boolean_state::create(endpoint, &(config->boolean_state), CLUSTER_FLAG_SERVER);
return ESP_OK;
}
} /* water_freeze_detector */
namespace rain_sensor { namespace rain_sensor {
uint32_t get_device_type_id() uint32_t get_device_type_id()
{ {
@@ -104,6 +104,8 @@
#define ESP_MATTER_ELECTRICAL_SENSOR_DEVICE_TYPE_VERSION 1 #define ESP_MATTER_ELECTRICAL_SENSOR_DEVICE_TYPE_VERSION 1
#define ESP_MATTER_OVEN_DEVICE_TYPE_ID 0x007B #define ESP_MATTER_OVEN_DEVICE_TYPE_ID 0x007B
#define ESP_MATTER_OVEN_DEVICE_TYPE_VERSION 1 #define ESP_MATTER_OVEN_DEVICE_TYPE_VERSION 1
#define ESP_MATTER_WATER_FREEZE_DETECTOR_DEVICE_TYPE_ID 0x0041
#define ESP_MATTER_WATER_FREEZE_DETECTOR_DEVICE_TYPE_VERSION 1
namespace esp_matter { namespace esp_matter {
@@ -638,6 +640,19 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat
esp_err_t add(endpoint_t *endpoint, config_t *config); esp_err_t add(endpoint_t *endpoint, config_t *config);
} /* water_leak_detector */ } /* water_leak_detector */
namespace water_freeze_detector {
typedef struct config {
cluster::descriptor::config_t descriptor;
cluster::identify::config_t identify;
cluster::boolean_state::config_t boolean_state;
} config_t;
uint32_t get_device_type_id();
uint8_t get_device_type_version();
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data);
esp_err_t add(endpoint_t *endpoint, config_t *config);
} /* water_freeze_detector */
namespace rain_sensor { namespace rain_sensor {
typedef struct config { typedef struct config {
cluster::descriptor::config_t descriptor; cluster::descriptor::config_t descriptor;
@@ -38,6 +38,7 @@ enum device_type_enum {
ESP_MATTER_DISH_WASHER, ESP_MATTER_DISH_WASHER,
ESP_MATTER_SMOKE_CO_ALARM, ESP_MATTER_SMOKE_CO_ALARM,
ESP_MATTER_WATER_LEAK_DETECTOR, ESP_MATTER_WATER_LEAK_DETECTOR,
ESP_MATTER_WATER_FREEZE_DETECTOR,
ESP_MATTER_POWER_SOURCE, ESP_MATTER_POWER_SOURCE,
ESP_MATTER_RAIN_SENSOR, ESP_MATTER_RAIN_SENSOR,
ESP_MATTER_ELECTRICAL_SENSOR, ESP_MATTER_ELECTRICAL_SENSOR,
@@ -86,9 +87,10 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = {
{"dish_washer", ESP_MATTER_DISH_WASHER}, {"dish_washer", ESP_MATTER_DISH_WASHER},
{"smoke_co_alarm", ESP_MATTER_SMOKE_CO_ALARM}, {"smoke_co_alarm", ESP_MATTER_SMOKE_CO_ALARM},
{"water_leak_detector", ESP_MATTER_WATER_LEAK_DETECTOR}, {"water_leak_detector", ESP_MATTER_WATER_LEAK_DETECTOR},
{"water_freeze_detector", ESP_MATTER_WATER_FREEZE_DETECTOR},
{"power_source", ESP_MATTER_POWER_SOURCE}, {"power_source", ESP_MATTER_POWER_SOURCE},
{"rain_sensor", ESP_MATTER_RAIN_SENSOR}, {"rain_sensor", ESP_MATTER_RAIN_SENSOR},
{"electrical_sensor", ESP_MATTER_ELECTRICAL_SENSOR}, {"electrical_sensor", ESP_MATTER_ELECTRICAL_SENSOR},
{"oven", ESP_MATTER_OVEN} {"oven", ESP_MATTER_OVEN}
}; };
} /* namespace esp_matter */ } /* namespace esp_matter */
@@ -375,6 +375,11 @@ int create(uint8_t device_type_index)
endpoint = esp_matter::endpoint::water_leak_detector::create(node, &water_leak_detector_config, ENDPOINT_FLAG_NONE, NULL); endpoint = esp_matter::endpoint::water_leak_detector::create(node, &water_leak_detector_config, ENDPOINT_FLAG_NONE, NULL);
break; break;
} }
case ESP_MATTER_WATER_FREEZE_DETECTOR: {
esp_matter::endpoint::water_freeze_detector::config_t water_freeze_detector_config;
endpoint = esp_matter::endpoint::water_freeze_detector::create(node, &water_freeze_detector_config, ENDPOINT_FLAG_NONE, NULL);
break;
}
case ESP_MATTER_POWER_SOURCE: { case ESP_MATTER_POWER_SOURCE: {
esp_matter::endpoint::power_source_device::config_t power_source_device_config; esp_matter::endpoint::power_source_device::config_t power_source_device_config;
endpoint = esp_matter::endpoint::power_source_device::create(node, &power_source_device_config, ENDPOINT_FLAG_NONE, NULL); endpoint = esp_matter::endpoint::power_source_device::create(node, &power_source_device_config, ENDPOINT_FLAG_NONE, NULL);