ESPHome 2025.5.0
Loading...
Searching...
No Matches
micronova_number.cpp
Go to the documentation of this file.
1#include "micronova_number.h"
2
3namespace esphome {
4namespace micronova {
5
6void MicroNovaNumber::process_value_from_stove(int value_from_stove) {
7 float new_sensor_value = 0;
8
9 if (value_from_stove == -1) {
10 this->publish_state(NAN);
11 return;
12 }
13
14 switch (this->get_function()) {
16 new_sensor_value = ((float) value_from_stove) * this->traits.get_step();
17 break;
19 new_sensor_value = (float) value_from_stove;
20 break;
21 default:
22 break;
23 }
24 this->publish_state(new_sensor_value);
25}
26
27void MicroNovaNumber::control(float value) {
28 uint8_t new_number = 0;
29
30 switch (this->get_function()) {
32 new_number = (uint8_t) (value / this->traits.get_step());
33 break;
35 new_number = (uint8_t) value;
36 break;
37 default:
38 break;
39 }
40 this->micronova_->write_address(this->memory_write_location_, this->memory_address_, new_number);
41 this->micronova_->update();
42}
43
44} // namespace micronova
45} // namespace esphome
void write_address(uint8_t location, uint8_t address, uint8_t data)
void control(float value) override
void process_value_from_stove(int value_from_stove) override
void publish_state(float state)
Definition number.cpp:9
NumberTraits traits
Definition number.h:49
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7