mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
components/esp-matter: Add Solar Power device type.
This commit is contained in:
@@ -83,6 +83,7 @@ i. Appliances
|
|||||||
j. Energy
|
j. Energy
|
||||||
1. EVSE (Electric Vehicle Supply Equipment)
|
1. EVSE (Electric Vehicle Supply Equipment)
|
||||||
2. Water Heater
|
2. Water Heater
|
||||||
|
3. Solar Power
|
||||||
|
|
||||||
k. Network Infrastructure
|
k. Network Infrastructure
|
||||||
1. Thread Border Router
|
1. Thread Border Router
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
static const char *TAG = "esp_matter_endpoint";
|
static const char *TAG = "esp_matter_endpoint";
|
||||||
|
|
||||||
|
using namespace chip::app::Clusters;
|
||||||
namespace esp_matter {
|
namespace esp_matter {
|
||||||
using namespace cluster;
|
using namespace cluster;
|
||||||
|
|
||||||
@@ -2050,6 +2051,53 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
|
|||||||
}
|
}
|
||||||
} /* water_heater */
|
} /* water_heater */
|
||||||
|
|
||||||
|
namespace solar_power {
|
||||||
|
uint32_t get_device_type_id()
|
||||||
|
{
|
||||||
|
return ESP_MATTER_SOLAR_POWER_DEVICE_TYPE_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t get_device_type_version()
|
||||||
|
{
|
||||||
|
return ESP_MATTER_SOLAR_POWER_DEVICE_TYPE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data)
|
||||||
|
{
|
||||||
|
return common::create<config_t>(node, config, flags, priv_data, add);
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t add(endpoint_t *endpoint, config_t *config)
|
||||||
|
{
|
||||||
|
VerifyOrReturnError(endpoint != nullptr, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Endpoint cannot be NULL"));
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
cluster_t *descriptor_cluster = cluster::get(endpoint, Descriptor::Id);
|
||||||
|
descriptor::feature::taglist::add(descriptor_cluster);
|
||||||
|
|
||||||
|
power_source_device::add(endpoint, &config->power_source_device);
|
||||||
|
|
||||||
|
cluster_t *power_source_cluster = cluster::get(endpoint, PowerSource::Id);
|
||||||
|
power_source::feature::wired::add(power_source_cluster, &config->power_source_device.power_source.wired);
|
||||||
|
|
||||||
|
electrical_sensor::add(endpoint, &config->electrical_sensor);
|
||||||
|
electrical_energy_measurement::create(endpoint, &(config->electrical_energy_measurement), CLUSTER_FLAG_SERVER, electrical_energy_measurement::feature::exported_energy::get_id() | electrical_energy_measurement::feature::cumulative_energy::get_id());
|
||||||
|
|
||||||
|
cluster_t *ele_power_measurement_cluster = cluster::get(endpoint, ElectricalPowerMeasurement::Id);
|
||||||
|
|
||||||
|
nullable<int64_t> voltage = 0, active_current = 0;
|
||||||
|
electrical_power_measurement::attribute::create_voltage(ele_power_measurement_cluster, voltage);
|
||||||
|
electrical_power_measurement::attribute::create_active_current(ele_power_measurement_cluster, active_current);
|
||||||
|
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
} /* solar_power */
|
||||||
|
|
||||||
} /* endpoint */
|
} /* endpoint */
|
||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
|
|||||||
@@ -138,6 +138,8 @@
|
|||||||
#define ESP_MATTER_SECONDARY_NETWORK_INTERFACE_DEVICE_TYPE_VERSION 1
|
#define ESP_MATTER_SECONDARY_NETWORK_INTERFACE_DEVICE_TYPE_VERSION 1
|
||||||
#define ESP_MATTER_WATER_HEATER_DEVICE_TYPE_ID 0x050F
|
#define ESP_MATTER_WATER_HEATER_DEVICE_TYPE_ID 0x050F
|
||||||
#define ESP_MATTER_WATER_HEATER_DEVICE_TYPE_VERSION 1
|
#define ESP_MATTER_WATER_HEATER_DEVICE_TYPE_VERSION 1
|
||||||
|
#define ESP_MATTER_SOLAR_POWER_DEVICE_TYPE_ID 0x0017
|
||||||
|
#define ESP_MATTER_SOLAR_POWER_DEVICE_TYPE_VERSION 1
|
||||||
|
|
||||||
#define ESP_MATTER_THREAD_BORDER_ROUTER_DEVICE_TYPE_ID 0x0091
|
#define ESP_MATTER_THREAD_BORDER_ROUTER_DEVICE_TYPE_ID 0x0091
|
||||||
#define ESP_MATTER_THREAD_BORDER_ROUTER_DEVICE_TYPE_VERSION 1
|
#define ESP_MATTER_THREAD_BORDER_ROUTER_DEVICE_TYPE_VERSION 1
|
||||||
@@ -844,6 +846,20 @@ 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_heater */
|
} /* water_heater */
|
||||||
|
|
||||||
|
namespace solar_power {
|
||||||
|
typedef struct config {
|
||||||
|
cluster::descriptor::config_t descriptor;
|
||||||
|
power_source_device::config_t power_source_device;
|
||||||
|
electrical_sensor::config_t electrical_sensor;
|
||||||
|
cluster::electrical_energy_measurement::config_t electrical_energy_measurement;
|
||||||
|
} 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);
|
||||||
|
} /* solar_power */
|
||||||
|
|
||||||
} /* endpoint */
|
} /* endpoint */
|
||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ enum device_type_enum {
|
|||||||
ESP_MATTER_MOUNTED_ON_OFF_CONTROL,
|
ESP_MATTER_MOUNTED_ON_OFF_CONTROL,
|
||||||
ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL,
|
ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL,
|
||||||
ESP_MATTER_WATER_HEATER,
|
ESP_MATTER_WATER_HEATER,
|
||||||
|
ESP_MATTER_SOLAR_POWER,
|
||||||
ESP_MATTER_DEVICE_TYPE_MAX
|
ESP_MATTER_DEVICE_TYPE_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -118,5 +119,6 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = {
|
|||||||
{"mounted_on_off_control", ESP_MATTER_MOUNTED_ON_OFF_CONTROL},
|
{"mounted_on_off_control", ESP_MATTER_MOUNTED_ON_OFF_CONTROL},
|
||||||
{"mounted_dimmable_load_control", ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL},
|
{"mounted_dimmable_load_control", ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL},
|
||||||
{"water_heater", ESP_MATTER_WATER_HEATER},
|
{"water_heater", ESP_MATTER_WATER_HEATER},
|
||||||
|
{"solar_power", ESP_MATTER_SOLAR_POWER},
|
||||||
};
|
};
|
||||||
} /* namespace esp_matter */
|
} /* namespace esp_matter */
|
||||||
|
|||||||
@@ -534,6 +534,11 @@ int create(uint8_t device_type_index)
|
|||||||
endpoint = esp_matter::endpoint::water_heater::create(node, &water_heater_config, ENDPOINT_FLAG_NONE, NULL);
|
endpoint = esp_matter::endpoint::water_heater::create(node, &water_heater_config, ENDPOINT_FLAG_NONE, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ESP_MATTER_SOLAR_POWER: {
|
||||||
|
esp_matter::endpoint::solar_power::config_t solar_power_config;
|
||||||
|
endpoint = esp_matter::endpoint::solar_power::create(node, &solar_power_config, ENDPOINT_FLAG_NONE, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
ESP_LOGE(TAG, "Please input a valid device type");
|
ESP_LOGE(TAG, "Please input a valid device type");
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user