Merge pull request #79 from syssi/add-fwe-support

This commit is contained in:
Jiří Bětuňák 2022-06-15 09:55:04 +02:00 committed by GitHub
commit a0f5353d40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 3 deletions

View File

@ -15,6 +15,7 @@ CONF_WARNING = "warning"
CONF_TRACKING_MODE = "tracking_mode"
CONF_DEVICE_MODE = "device_mode"
CONF_FIRMWARE_VERSION = "firmware_version"
CONF_FIRMWARE_VERSION_24BIT = "firmware_version_24bit"
CONF_DEVICE_TYPE = "device_type"
CONF_SERIAL_NUMBER = "serial_number"
@ -29,6 +30,7 @@ TEXT_SENSORS = [
CONF_TRACKING_MODE,
CONF_DEVICE_MODE,
CONF_FIRMWARE_VERSION,
CONF_FIRMWARE_VERSION_24BIT,
CONF_DEVICE_TYPE,
CONF_SERIAL_NUMBER,
#
@ -59,6 +61,9 @@ CONFIG_SCHEMA = cv.Schema(
cv.Optional(CONF_FIRMWARE_VERSION): text_sensor.TEXT_SENSOR_SCHEMA.extend(
{cv.GenerateID(): cv.declare_id(text_sensor.TextSensor)}
),
cv.Optional(CONF_FIRMWARE_VERSION_24BIT): text_sensor.TEXT_SENSOR_SCHEMA.extend(
{cv.GenerateID(): cv.declare_id(text_sensor.TextSensor)}
),
cv.Optional(CONF_DEVICE_TYPE): text_sensor.TEXT_SENSOR_SCHEMA.extend(
{cv.GenerateID(): cv.declare_id(text_sensor.TextSensor)}
),

View File

@ -7,7 +7,7 @@ namespace victron {
static const char *const TAG = "victron";
void VictronComponent::dump_config() {
void VictronComponent::dump_config() { // NOLINT(google-readability-function-size,readability-function-size)
ESP_LOGCONFIG(TAG, "Victron:");
LOG_BINARY_SENSOR(" ", "Load state", load_state_binary_sensor_);
LOG_BINARY_SENSOR(" ", "Relay state", relay_state_binary_sensor_);
@ -39,6 +39,7 @@ void VictronComponent::dump_config() {
LOG_TEXT_SENSOR(" ", "Tracking Mode", tracking_mode_text_sensor_);
LOG_TEXT_SENSOR(" ", "Device Mode", device_mode_text_sensor_);
LOG_TEXT_SENSOR(" ", "Firmware Version", firmware_version_text_sensor_);
LOG_TEXT_SENSOR(" ", "Firmware Version 24bit", firmware_version_24bit_text_sensor_);
LOG_TEXT_SENSOR(" ", "Device Type", device_type_text_sensor_);
LOG_SENSOR(" ", "Battery Temperature ", battery_temperature_sensor_);
@ -849,7 +850,10 @@ void VictronComponent::handle_value_() {
return;
}
// @TODO: "FWE" Firmware version (24 bit)
if (label_ == "FWE") {
this->publish_state_once_(firmware_version_24bit_text_sensor_, value_);
return;
}
if (label_ == "PID") {
this->publish_state_once_(device_type_text_sensor_, device_type_text(strtol(value_.c_str(), nullptr, 0)));

View File

@ -98,6 +98,9 @@ class VictronComponent : public uart::UARTDevice, public Component {
void set_firmware_version_text_sensor(text_sensor::TextSensor *firmware_version_text_sensor) {
firmware_version_text_sensor_ = firmware_version_text_sensor;
}
void set_firmware_version_24bit_text_sensor(text_sensor::TextSensor *firmware_version_24bit_text_sensor) {
firmware_version_24bit_text_sensor_ = firmware_version_24bit_text_sensor;
}
void set_device_type_text_sensor(text_sensor::TextSensor *device_type_text_sensor) {
device_type_text_sensor_ = device_type_text_sensor;
}
@ -233,6 +236,7 @@ class VictronComponent : public uart::UARTDevice, public Component {
text_sensor::TextSensor *tracking_mode_text_sensor_{nullptr};
text_sensor::TextSensor *device_mode_text_sensor_{nullptr};
text_sensor::TextSensor *firmware_version_text_sensor_{nullptr};
text_sensor::TextSensor *firmware_version_24bit_text_sensor_{nullptr};
text_sensor::TextSensor *device_type_text_sensor_{nullptr};
text_sensor::TextSensor *serial_number_text_sensor_{nullptr};

View File

@ -79,7 +79,8 @@ text_sensor:
name: "${name} device type"
serial_number:
name: "${name} serial number"
# TODO: FWE
firmware_version_24bit:
name: "${name} firmware version 24bit"
charging_mode:
name: "${name} charging mode"
error: