mirror of
https://github.com/esphome/esphome.git
synced 2026-06-02 03:02:19 +08:00
[micronova] Remove MicroNovaFunctions (#12363)
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled
Stale / stale (push) Has been cancelled
Lock closed issues and PRs / lock (push) Has been cancelled
Publish Release / Initialize build (push) Has been cancelled
Publish Release / Build and publish to PyPi (push) Has been cancelled
Publish Release / Build ESPHome amd64 (push) Has been cancelled
Publish Release / Build ESPHome arm64 (push) Has been cancelled
Publish Release / Publish ESPHome docker to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome docker to ghcr (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to ghcr (push) Has been cancelled
Publish Release / deploy-ha-addon-repo (push) Has been cancelled
Publish Release / deploy-esphome-schema (push) Has been cancelled
Publish Release / version-notifier (push) Has been cancelled
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled
Stale / stale (push) Has been cancelled
Lock closed issues and PRs / lock (push) Has been cancelled
Publish Release / Initialize build (push) Has been cancelled
Publish Release / Build and publish to PyPi (push) Has been cancelled
Publish Release / Build ESPHome amd64 (push) Has been cancelled
Publish Release / Build ESPHome arm64 (push) Has been cancelled
Publish Release / Publish ESPHome docker to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome docker to ghcr (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to dockerhub (push) Has been cancelled
Publish Release / Publish ESPHome ha-addon to ghcr (push) Has been cancelled
Publish Release / deploy-ha-addon-repo (push) Has been cancelled
Publish Release / deploy-esphome-schema (push) Has been cancelled
Publish Release / version-notifier (push) Has been cancelled
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -17,22 +17,6 @@ DEFAULT_POLLING_INTERVAL = "60s"
|
|||||||
|
|
||||||
micronova_ns = cg.esphome_ns.namespace(DOMAIN)
|
micronova_ns = cg.esphome_ns.namespace(DOMAIN)
|
||||||
|
|
||||||
MicroNovaFunctions = micronova_ns.enum("MicroNovaFunctions", is_class=True)
|
|
||||||
MICRONOVA_FUNCTIONS_ENUM = {
|
|
||||||
"STOVE_FUNCTION_SWITCH": MicroNovaFunctions.STOVE_FUNCTION_SWITCH,
|
|
||||||
"STOVE_FUNCTION_ROOM_TEMPERATURE": MicroNovaFunctions.STOVE_FUNCTION_ROOM_TEMPERATURE,
|
|
||||||
"STOVE_FUNCTION_THERMOSTAT_TEMPERATURE": MicroNovaFunctions.STOVE_FUNCTION_THERMOSTAT_TEMPERATURE,
|
|
||||||
"STOVE_FUNCTION_FUMES_TEMPERATURE": MicroNovaFunctions.STOVE_FUNCTION_FUMES_TEMPERATURE,
|
|
||||||
"STOVE_FUNCTION_STOVE_POWER": MicroNovaFunctions.STOVE_FUNCTION_STOVE_POWER,
|
|
||||||
"STOVE_FUNCTION_FAN_SPEED": MicroNovaFunctions.STOVE_FUNCTION_FAN_SPEED,
|
|
||||||
"STOVE_FUNCTION_STOVE_STATE": MicroNovaFunctions.STOVE_FUNCTION_STOVE_STATE,
|
|
||||||
"STOVE_FUNCTION_MEMORY_ADDRESS_SENSOR": MicroNovaFunctions.STOVE_FUNCTION_MEMORY_ADDRESS_SENSOR,
|
|
||||||
"STOVE_FUNCTION_WATER_TEMPERATURE": MicroNovaFunctions.STOVE_FUNCTION_WATER_TEMPERATURE,
|
|
||||||
"STOVE_FUNCTION_WATER_PRESSURE": MicroNovaFunctions.STOVE_FUNCTION_WATER_PRESSURE,
|
|
||||||
"STOVE_FUNCTION_POWER_LEVEL": MicroNovaFunctions.STOVE_FUNCTION_POWER_LEVEL,
|
|
||||||
"STOVE_FUNCTION_CUSTOM": MicroNovaFunctions.STOVE_FUNCTION_CUSTOM,
|
|
||||||
}
|
|
||||||
|
|
||||||
MicroNova = micronova_ns.class_("MicroNova", cg.Component, uart.UARTDevice)
|
MicroNova = micronova_ns.class_("MicroNova", cg.Component, uart.UARTDevice)
|
||||||
MicroNovaListener = micronova_ns.class_("MicroNovaListener", cg.PollingComponent)
|
MicroNovaListener = micronova_ns.class_("MicroNovaListener", cg.PollingComponent)
|
||||||
|
|
||||||
@@ -78,12 +62,11 @@ def MICRONOVA_ADDRESS_SCHEMA(
|
|||||||
return schema
|
return schema
|
||||||
|
|
||||||
|
|
||||||
async def to_code_micronova_listener(mv, var, config, micronova_function):
|
async def to_code_micronova_listener(mv, var, config):
|
||||||
await cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
cg.add(mv.register_micronova_listener(var))
|
cg.add(mv.register_micronova_listener(var))
|
||||||
cg.add(var.set_memory_location(config[CONF_MEMORY_LOCATION]))
|
cg.add(var.set_memory_location(config[CONF_MEMORY_LOCATION]))
|
||||||
cg.add(var.set_memory_address(config[CONF_MEMORY_ADDRESS]))
|
cg.add(var.set_memory_address(config[CONF_MEMORY_ADDRESS]))
|
||||||
cg.add(var.set_function(micronova_function))
|
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ from .. import (
|
|||||||
CONF_MICRONOVA_ID,
|
CONF_MICRONOVA_ID,
|
||||||
MICRONOVA_ADDRESS_SCHEMA,
|
MICRONOVA_ADDRESS_SCHEMA,
|
||||||
MicroNova,
|
MicroNova,
|
||||||
MicroNovaFunctions,
|
|
||||||
micronova_ns,
|
micronova_ns,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -43,4 +42,3 @@ async def to_code(config):
|
|||||||
cg.add(bt.set_memory_location(custom_button_config.get(CONF_MEMORY_LOCATION)))
|
cg.add(bt.set_memory_location(custom_button_config.get(CONF_MEMORY_LOCATION)))
|
||||||
cg.add(bt.set_memory_address(custom_button_config.get(CONF_MEMORY_ADDRESS)))
|
cg.add(bt.set_memory_address(custom_button_config.get(CONF_MEMORY_ADDRESS)))
|
||||||
cg.add(bt.set_memory_data(custom_button_config[CONF_MEMORY_DATA]))
|
cg.add(bt.set_memory_data(custom_button_config[CONF_MEMORY_DATA]))
|
||||||
cg.add(bt.set_function(MicroNovaFunctions.STOVE_FUNCTION_CUSTOM))
|
|
||||||
|
|||||||
@@ -3,13 +3,7 @@
|
|||||||
namespace esphome::micronova {
|
namespace esphome::micronova {
|
||||||
|
|
||||||
void MicroNovaButton::press_action() {
|
void MicroNovaButton::press_action() {
|
||||||
switch (this->get_function()) {
|
this->micronova_->write_address(this->memory_location_, this->memory_address_, this->memory_data_);
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_CUSTOM:
|
|
||||||
this->micronova_->write_address(this->memory_location_, this->memory_address_, this->memory_data_);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this->micronova_->request_update_listeners();
|
this->micronova_->request_update_listeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,22 +12,6 @@ namespace esphome::micronova {
|
|||||||
|
|
||||||
static const char *const TAG = "micronova";
|
static const char *const TAG = "micronova";
|
||||||
|
|
||||||
enum class MicroNovaFunctions {
|
|
||||||
STOVE_FUNCTION_VOID = 0,
|
|
||||||
STOVE_FUNCTION_SWITCH = 1,
|
|
||||||
STOVE_FUNCTION_ROOM_TEMPERATURE = 2,
|
|
||||||
STOVE_FUNCTION_THERMOSTAT_TEMPERATURE = 3,
|
|
||||||
STOVE_FUNCTION_FUMES_TEMPERATURE = 4,
|
|
||||||
STOVE_FUNCTION_STOVE_POWER = 5,
|
|
||||||
STOVE_FUNCTION_FAN_SPEED = 6,
|
|
||||||
STOVE_FUNCTION_STOVE_STATE = 7,
|
|
||||||
STOVE_FUNCTION_MEMORY_ADDRESS_SENSOR = 8,
|
|
||||||
STOVE_FUNCTION_WATER_TEMPERATURE = 9,
|
|
||||||
STOVE_FUNCTION_WATER_PRESSURE = 10,
|
|
||||||
STOVE_FUNCTION_POWER_LEVEL = 11,
|
|
||||||
STOVE_FUNCTION_CUSTOM = 12
|
|
||||||
};
|
|
||||||
|
|
||||||
class MicroNova;
|
class MicroNova;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@@ -39,9 +23,6 @@ class MicroNovaBaseListener {
|
|||||||
|
|
||||||
void set_micronova_object(MicroNova *m) { this->micronova_ = m; }
|
void set_micronova_object(MicroNova *m) { this->micronova_ = m; }
|
||||||
|
|
||||||
void set_function(MicroNovaFunctions f) { this->function_ = f; }
|
|
||||||
MicroNovaFunctions get_function() { return this->function_; }
|
|
||||||
|
|
||||||
void set_memory_location(uint8_t l) { this->memory_location_ = l; }
|
void set_memory_location(uint8_t l) { this->memory_location_ = l; }
|
||||||
uint8_t get_memory_location() { return this->memory_location_; }
|
uint8_t get_memory_location() { return this->memory_location_; }
|
||||||
|
|
||||||
@@ -52,7 +33,6 @@ class MicroNovaBaseListener {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
MicroNova *micronova_{nullptr};
|
MicroNova *micronova_{nullptr};
|
||||||
MicroNovaFunctions function_ = MicroNovaFunctions::STOVE_FUNCTION_VOID;
|
|
||||||
uint8_t memory_location_ = 0;
|
uint8_t memory_location_ = 0;
|
||||||
uint8_t memory_address_ = 0;
|
uint8_t memory_address_ = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from .. import (
|
|||||||
CONF_MICRONOVA_ID,
|
CONF_MICRONOVA_ID,
|
||||||
MICRONOVA_ADDRESS_SCHEMA,
|
MICRONOVA_ADDRESS_SCHEMA,
|
||||||
MicroNova,
|
MicroNova,
|
||||||
MicroNovaFunctions,
|
|
||||||
MicroNovaListener,
|
MicroNovaListener,
|
||||||
micronova_ns,
|
micronova_ns,
|
||||||
to_code_micronova_listener,
|
to_code_micronova_listener,
|
||||||
@@ -66,13 +65,9 @@ async def to_code(config):
|
|||||||
max_value=40,
|
max_value=40,
|
||||||
step=thermostat_temperature_config.get(CONF_STEP),
|
step=thermostat_temperature_config.get(CONF_STEP),
|
||||||
)
|
)
|
||||||
await to_code_micronova_listener(
|
await to_code_micronova_listener(mv, numb, thermostat_temperature_config)
|
||||||
mv,
|
|
||||||
numb,
|
|
||||||
thermostat_temperature_config,
|
|
||||||
MicroNovaFunctions.STOVE_FUNCTION_THERMOSTAT_TEMPERATURE,
|
|
||||||
)
|
|
||||||
cg.add(numb.set_micronova_object(mv))
|
cg.add(numb.set_micronova_object(mv))
|
||||||
|
cg.add(numb.set_use_step_scaling(True))
|
||||||
|
|
||||||
if power_level_config := config.get(CONF_POWER_LEVEL):
|
if power_level_config := config.get(CONF_POWER_LEVEL):
|
||||||
numb = await number.new_number(
|
numb = await number.new_number(
|
||||||
@@ -81,7 +76,5 @@ async def to_code(config):
|
|||||||
max_value=5,
|
max_value=5,
|
||||||
step=1,
|
step=1,
|
||||||
)
|
)
|
||||||
await to_code_micronova_listener(
|
await to_code_micronova_listener(mv, numb, power_level_config)
|
||||||
mv, numb, power_level_config, MicroNovaFunctions.STOVE_FUNCTION_POWER_LEVEL
|
|
||||||
)
|
|
||||||
cg.add(numb.set_micronova_object(mv))
|
cg.add(numb.set_micronova_object(mv))
|
||||||
|
|||||||
@@ -3,38 +3,24 @@
|
|||||||
namespace esphome::micronova {
|
namespace esphome::micronova {
|
||||||
|
|
||||||
void MicroNovaNumber::process_value_from_stove(int value_from_stove) {
|
void MicroNovaNumber::process_value_from_stove(int value_from_stove) {
|
||||||
float new_sensor_value = 0;
|
|
||||||
|
|
||||||
if (value_from_stove == -1) {
|
if (value_from_stove == -1) {
|
||||||
this->publish_state(NAN);
|
this->publish_state(NAN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this->get_function()) {
|
float new_value = static_cast<float>(value_from_stove);
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_THERMOSTAT_TEMPERATURE:
|
if (this->use_step_scaling_) {
|
||||||
new_sensor_value = ((float) value_from_stove) * this->traits.get_step();
|
new_value *= this->traits.get_step();
|
||||||
break;
|
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_POWER_LEVEL:
|
|
||||||
new_sensor_value = (float) value_from_stove;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
this->publish_state(new_sensor_value);
|
this->publish_state(new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MicroNovaNumber::control(float value) {
|
void MicroNovaNumber::control(float value) {
|
||||||
uint8_t new_number = 0;
|
uint8_t new_number;
|
||||||
|
if (this->use_step_scaling_) {
|
||||||
switch (this->get_function()) {
|
new_number = static_cast<uint8_t>(value / this->traits.get_step());
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_THERMOSTAT_TEMPERATURE:
|
} else {
|
||||||
new_number = (uint8_t) (value / this->traits.get_step());
|
new_number = static_cast<uint8_t>(value);
|
||||||
break;
|
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_POWER_LEVEL:
|
|
||||||
new_number = (uint8_t) value;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
this->micronova_->write_address(this->memory_location_, this->memory_address_, new_number);
|
this->micronova_->write_address(this->memory_location_, this->memory_address_, new_number);
|
||||||
this->micronova_->request_update_listeners();
|
this->micronova_->request_update_listeners();
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ class MicroNovaNumber : public number::Number, public MicroNovaListener {
|
|||||||
this->micronova_->request_address(this->memory_location_, this->memory_address_, this);
|
this->micronova_->request_address(this->memory_location_, this->memory_address_, this);
|
||||||
}
|
}
|
||||||
void process_value_from_stove(int value_from_stove) override;
|
void process_value_from_stove(int value_from_stove) override;
|
||||||
|
|
||||||
|
void set_use_step_scaling(bool v) { this->use_step_scaling_ = v; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool use_step_scaling_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace esphome::micronova
|
} // namespace esphome::micronova
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ from .. import (
|
|||||||
CONF_MICRONOVA_ID,
|
CONF_MICRONOVA_ID,
|
||||||
MICRONOVA_ADDRESS_SCHEMA,
|
MICRONOVA_ADDRESS_SCHEMA,
|
||||||
MicroNova,
|
MicroNova,
|
||||||
MicroNovaFunctions,
|
|
||||||
MicroNovaListener,
|
MicroNovaListener,
|
||||||
micronova_ns,
|
micronova_ns,
|
||||||
to_code_micronova_listener,
|
to_code_micronova_listener,
|
||||||
@@ -131,21 +130,21 @@ CONFIG_SCHEMA = cv.Schema(
|
|||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
mv = await cg.get_variable(config[CONF_MICRONOVA_ID])
|
mv = await cg.get_variable(config[CONF_MICRONOVA_ID])
|
||||||
|
|
||||||
for key, fn in {
|
for key, divisor in {
|
||||||
CONF_ROOM_TEMPERATURE: MicroNovaFunctions.STOVE_FUNCTION_ROOM_TEMPERATURE,
|
CONF_ROOM_TEMPERATURE: 2,
|
||||||
CONF_FUMES_TEMPERATURE: MicroNovaFunctions.STOVE_FUNCTION_FUMES_TEMPERATURE,
|
CONF_FUMES_TEMPERATURE: None,
|
||||||
CONF_STOVE_POWER: MicroNovaFunctions.STOVE_FUNCTION_STOVE_POWER,
|
CONF_STOVE_POWER: None,
|
||||||
CONF_MEMORY_ADDRESS_SENSOR: MicroNovaFunctions.STOVE_FUNCTION_MEMORY_ADDRESS_SENSOR,
|
CONF_MEMORY_ADDRESS_SENSOR: None,
|
||||||
CONF_WATER_TEMPERATURE: MicroNovaFunctions.STOVE_FUNCTION_WATER_TEMPERATURE,
|
CONF_WATER_TEMPERATURE: 2,
|
||||||
CONF_WATER_PRESSURE: MicroNovaFunctions.STOVE_FUNCTION_WATER_PRESSURE,
|
CONF_WATER_PRESSURE: 10,
|
||||||
}.items():
|
}.items():
|
||||||
if sensor_config := config.get(key):
|
if sensor_config := config.get(key):
|
||||||
sens = await sensor.new_sensor(sensor_config, mv)
|
sens = await sensor.new_sensor(sensor_config, mv)
|
||||||
await to_code_micronova_listener(mv, sens, sensor_config, fn)
|
await to_code_micronova_listener(mv, sens, sensor_config)
|
||||||
|
if divisor:
|
||||||
|
cg.add(sens.set_divisor(divisor))
|
||||||
|
|
||||||
if fan_speed_config := config.get(CONF_FAN_SPEED):
|
if fan_speed_config := config.get(CONF_FAN_SPEED):
|
||||||
sens = await sensor.new_sensor(fan_speed_config, mv)
|
sens = await sensor.new_sensor(fan_speed_config, mv)
|
||||||
await to_code_micronova_listener(
|
await to_code_micronova_listener(mv, sens, fan_speed_config)
|
||||||
mv, sens, fan_speed_config, MicroNovaFunctions.STOVE_FUNCTION_FAN_SPEED
|
|
||||||
)
|
|
||||||
cg.add(sens.set_fan_speed_offset(fan_speed_config[CONF_FAN_RPM_OFFSET]))
|
cg.add(sens.set_fan_speed_offset(fan_speed_config[CONF_FAN_RPM_OFFSET]))
|
||||||
|
|||||||
@@ -8,25 +8,15 @@ void MicroNovaSensor::process_value_from_stove(int value_from_stove) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float new_sensor_value = (float) value_from_stove;
|
float new_sensor_value = static_cast<float>(value_from_stove);
|
||||||
switch (this->get_function()) {
|
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_ROOM_TEMPERATURE:
|
// Fan speed has special calculation: value * 10 + offset (when non-zero)
|
||||||
new_sensor_value = new_sensor_value / 2;
|
if (this->is_fan_speed_) {
|
||||||
break;
|
new_sensor_value = value_from_stove == 0 ? 0.0f : (new_sensor_value * 10) + this->fan_speed_offset_;
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_THERMOSTAT_TEMPERATURE:
|
} else if (this->divisor_ > 1) {
|
||||||
break;
|
new_sensor_value = new_sensor_value / this->divisor_;
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_FAN_SPEED:
|
|
||||||
new_sensor_value = new_sensor_value == 0 ? 0 : (new_sensor_value * 10) + this->fan_speed_offset_;
|
|
||||||
break;
|
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_WATER_TEMPERATURE:
|
|
||||||
new_sensor_value = new_sensor_value / 2;
|
|
||||||
break;
|
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_WATER_PRESSURE:
|
|
||||||
new_sensor_value = new_sensor_value / 10;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->publish_state(new_sensor_value);
|
this->publish_state(new_sensor_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,16 @@ class MicroNovaSensor : public sensor::Sensor, public MicroNovaListener {
|
|||||||
}
|
}
|
||||||
void process_value_from_stove(int value_from_stove) override;
|
void process_value_from_stove(int value_from_stove) override;
|
||||||
|
|
||||||
void set_fan_speed_offset(uint8_t f) { this->fan_speed_offset_ = f; }
|
void set_divisor(uint8_t d) { this->divisor_ = d; }
|
||||||
uint8_t get_set_fan_speed_offset() { return this->fan_speed_offset_; }
|
void set_fan_speed_offset(uint8_t offset) {
|
||||||
|
this->is_fan_speed_ = true;
|
||||||
|
this->fan_speed_offset_ = offset;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int fan_speed_offset_ = 0;
|
uint8_t divisor_ = 1;
|
||||||
|
uint8_t fan_speed_offset_ = 0;
|
||||||
|
bool is_fan_speed_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace esphome::micronova
|
} // namespace esphome::micronova
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from .. import (
|
|||||||
CONF_MICRONOVA_ID,
|
CONF_MICRONOVA_ID,
|
||||||
MICRONOVA_ADDRESS_SCHEMA,
|
MICRONOVA_ADDRESS_SCHEMA,
|
||||||
MicroNova,
|
MicroNova,
|
||||||
MicroNovaFunctions,
|
|
||||||
MicroNovaListener,
|
MicroNovaListener,
|
||||||
micronova_ns,
|
micronova_ns,
|
||||||
to_code_micronova_listener,
|
to_code_micronova_listener,
|
||||||
@@ -50,8 +49,6 @@ async def to_code(config):
|
|||||||
|
|
||||||
if stove_config := config.get(CONF_STOVE):
|
if stove_config := config.get(CONF_STOVE):
|
||||||
sw = await switch.new_switch(stove_config, mv)
|
sw = await switch.new_switch(stove_config, mv)
|
||||||
await to_code_micronova_listener(
|
await to_code_micronova_listener(mv, sw, stove_config)
|
||||||
mv, sw, stove_config, MicroNovaFunctions.STOVE_FUNCTION_SWITCH
|
|
||||||
)
|
|
||||||
cg.add(sw.set_memory_data_on(stove_config[CONF_MEMORY_DATA_ON]))
|
cg.add(sw.set_memory_data_on(stove_config[CONF_MEMORY_DATA_ON]))
|
||||||
cg.add(sw.set_memory_data_off(stove_config[CONF_MEMORY_DATA_OFF]))
|
cg.add(sw.set_memory_data_off(stove_config[CONF_MEMORY_DATA_OFF]))
|
||||||
|
|||||||
@@ -3,31 +3,24 @@
|
|||||||
namespace esphome::micronova {
|
namespace esphome::micronova {
|
||||||
|
|
||||||
void MicroNovaSwitch::write_state(bool state) {
|
void MicroNovaSwitch::write_state(bool state) {
|
||||||
switch (this->get_function()) {
|
if (state) {
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_SWITCH: {
|
// Only send power-on when current state is Off
|
||||||
if (state) {
|
if (this->raw_state_ == 0) {
|
||||||
// Only send power-on when current state is Off
|
this->micronova_->write_address(this->memory_location_, this->memory_address_, this->memory_data_on_);
|
||||||
if (this->raw_state_ == 0) {
|
this->publish_state(true);
|
||||||
this->micronova_->write_address(this->memory_location_, this->memory_address_, this->memory_data_on_);
|
} else {
|
||||||
this->publish_state(true);
|
ESP_LOGW(TAG, "Unable to turn stove on, invalid state: %d", this->raw_state_);
|
||||||
} else {
|
}
|
||||||
ESP_LOGW(TAG, "Unable to turn stove on, invalid state: %d", this->raw_state_);
|
} else {
|
||||||
}
|
// don't send power-off when status is Off or Final cleaning
|
||||||
} else {
|
if (this->raw_state_ != 0 && this->raw_state_ != 6) {
|
||||||
// don't send power-off when status is Off or Final cleaning
|
this->micronova_->write_address(this->memory_location_, this->memory_address_, this->memory_data_off_);
|
||||||
if (this->raw_state_ != 0 && this->raw_state_ != 6) {
|
this->publish_state(false);
|
||||||
this->micronova_->write_address(this->memory_location_, this->memory_address_, this->memory_data_off_);
|
} else {
|
||||||
this->publish_state(false);
|
ESP_LOGW(TAG, "Unable to turn stove off, invalid state: %d", this->raw_state_);
|
||||||
} else {
|
|
||||||
ESP_LOGW(TAG, "Unable to turn stove off, invalid state: %d", this->raw_state_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->set_needs_update(true);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
this->set_needs_update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MicroNovaSwitch::process_value_from_stove(int value_from_stove) {
|
void MicroNovaSwitch::process_value_from_stove(int value_from_stove) {
|
||||||
@@ -37,16 +30,9 @@ void MicroNovaSwitch::process_value_from_stove(int value_from_stove) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this->get_function()) {
|
// set the stove switch to on for any value but 0
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_SWITCH: {
|
bool state = value_from_stove != 0;
|
||||||
// set the stove switch to on for any value but 0
|
this->publish_state(state);
|
||||||
bool state = value_from_stove != 0;
|
|
||||||
this->publish_state(state);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace esphome::micronova
|
} // namespace esphome::micronova
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from .. import (
|
|||||||
CONF_MICRONOVA_ID,
|
CONF_MICRONOVA_ID,
|
||||||
MICRONOVA_ADDRESS_SCHEMA,
|
MICRONOVA_ADDRESS_SCHEMA,
|
||||||
MicroNova,
|
MicroNova,
|
||||||
MicroNovaFunctions,
|
|
||||||
MicroNovaListener,
|
MicroNovaListener,
|
||||||
micronova_ns,
|
micronova_ns,
|
||||||
to_code_micronova_listener,
|
to_code_micronova_listener,
|
||||||
@@ -39,6 +38,4 @@ async def to_code(config):
|
|||||||
|
|
||||||
if stove_state_config := config.get(CONF_STOVE_STATE):
|
if stove_state_config := config.get(CONF_STOVE_STATE):
|
||||||
sens = await text_sensor.new_text_sensor(stove_state_config, mv)
|
sens = await text_sensor.new_text_sensor(stove_state_config, mv)
|
||||||
await to_code_micronova_listener(
|
await to_code_micronova_listener(mv, sens, stove_state_config)
|
||||||
mv, sens, stove_state_config, MicroNovaFunctions.STOVE_FUNCTION_STOVE_STATE
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -8,13 +8,7 @@ void MicroNovaTextSensor::process_value_from_stove(int value_from_stove) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this->get_function()) {
|
this->publish_state(STOVE_STATES[value_from_stove]);
|
||||||
case MicroNovaFunctions::STOVE_FUNCTION_STOVE_STATE:
|
|
||||||
this->publish_state(STOVE_STATES[value_from_stove]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace esphome::micronova
|
} // namespace esphome::micronova
|
||||||
|
|||||||
Reference in New Issue
Block a user