ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
setpoint.cpp
Go to the documentation of this file.
1#include "setpoint.h"
2
3#include <cmath>
4
5namespace esphome::duco {
6
7void DucoSetpoint::update() { this->parent_->send(this, FUNCTION_NODE_SETTING, {0x00, this->address_, this->item_}); }
8
10 if (message.size < 3) {
11 // A write is acknowledged with a single 0x01: read the stored value back
12 if (message.size == 1 && message.data[0] == 0x01)
13 this->update();
14 return;
15 }
16 // Setpoint responses are little-endian, while writes are big-endian.
17 this->publish_state(encode_uint16(message.data[2], message.data[1]));
18}
19
21 const auto setpoint = static_cast<uint16_t>(lroundf(value));
22 this->parent_->send(
23 this, FUNCTION_NODE_SETTING,
24 {0x01, this->address_, this->item_, static_cast<uint8_t>(setpoint >> 8), static_cast<uint8_t>(setpoint)});
25}
26
27} // namespace esphome::duco
void control(float value) override
Definition setpoint.cpp:20
void receive_response(const DucoMessage &message) override
Definition setpoint.cpp:9
void update() override
Definition setpoint.cpp:7
void publish_state(float state)
Definition number.cpp:20
const LogString * message
Definition component.cpp:35
uint32_t value
Definition hal.cpp:59
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
Definition helpers.h:1227
A received message; data points into the receive buffer and is valid only during the callback.
Definition duco.h:34
const uint8_t * data
Definition duco.h:36