fix formatting for maidesite desk
This commit is contained in:
parent
ee4bf34083
commit
921eb6387e
|
|
@ -4,30 +4,32 @@ from esphome import pins
|
||||||
from esphome.components import uart
|
from esphome.components import uart
|
||||||
from esphome.const import CONF_ID
|
from esphome.const import CONF_ID
|
||||||
|
|
||||||
CODEOWNERS = ['@elvit']
|
CODEOWNERS = ["@elvit"]
|
||||||
MULTICONF = True
|
MULTICONF = True
|
||||||
DEPENDENCIES = ['uart']
|
DEPENDENCIES = ["uart"]
|
||||||
|
|
||||||
CONF_MAIDESITE_DESK_ID = "maidesite_desk"
|
CONF_MAIDESITE_DESK_ID = "maidesite_desk"
|
||||||
CONF_LOG_UART_MSG = "log_uart_msg"
|
CONF_LOG_UART_MSG = "log_uart_msg"
|
||||||
|
|
||||||
maidesite_desk_ns = cg.esphome_ns.namespace('maidesite_desk')
|
maidesite_desk_ns = cg.esphome_ns.namespace("maidesite_desk")
|
||||||
MaidesiteDeskComponent = maidesite_desk_ns.class_('MaidesiteDeskComponent', cg.Component, uart.UARTDevice)
|
MaidesiteDeskComponent = maidesite_desk_ns.class_(
|
||||||
|
"MaidesiteDeskComponent", cg.Component, uart.UARTDevice
|
||||||
CONFIG_SCHEMA = (
|
|
||||||
cv.Schema(
|
|
||||||
{
|
|
||||||
cv.GenerateID(): cv.declare_id(MaidesiteDeskComponent),
|
|
||||||
|
|
||||||
cv.Optional(CONF_LOG_UART_MSG, default=False): cv.boolean,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.extend(uart.UART_DEVICE_SCHEMA)
|
|
||||||
.extend(cv.COMPONENT_SCHEMA)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = (
|
||||||
|
cv.Schema(
|
||||||
|
{
|
||||||
|
cv.GenerateID(): cv.declare_id(MaidesiteDeskComponent),
|
||||||
|
cv.Optional(CONF_LOG_UART_MSG, default=False): cv.boolean,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.extend(uart.UART_DEVICE_SCHEMA)
|
||||||
|
.extend(cv.COMPONENT_SCHEMA)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
await cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
await uart.register_uart_device(var, config)
|
await uart.register_uart_device(var, config)
|
||||||
cg.add(var.set_log_uart_msg(config[CONF_LOG_UART_MSG]))
|
cg.add(var.set_log_uart_msg(config[CONF_LOG_UART_MSG]))
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,10 @@ import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.components import button
|
from esphome.components import button
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
ENTITY_CATEGORY_CONFIG,
|
ENTITY_CATEGORY_CONFIG,
|
||||||
)
|
)
|
||||||
from .. import CONF_MAIDESITE_DESK_ID, MaidesiteDeskComponent, maidesite_desk_ns
|
from .. import CONF_MAIDESITE_DESK_ID, MaidesiteDeskComponent, maidesite_desk_ns
|
||||||
|
|
||||||
|
|
||||||
CONF_STEP_UP = "step_up"
|
CONF_STEP_UP = "step_up"
|
||||||
CONF_STEP_DOWN = "step_down"
|
CONF_STEP_DOWN = "step_down"
|
||||||
CONF_STOP = "stop"
|
CONF_STOP = "stop"
|
||||||
|
|
@ -22,79 +21,81 @@ CONF_SAVE_M3 = "save_m3"
|
||||||
CONF_SAVE_M4 = "save_m4"
|
CONF_SAVE_M4 = "save_m4"
|
||||||
|
|
||||||
TYPES = [
|
TYPES = [
|
||||||
CONF_STEP_UP,
|
CONF_STEP_UP,
|
||||||
CONF_STEP_DOWN,
|
CONF_STEP_DOWN,
|
||||||
CONF_STOP,
|
CONF_STOP,
|
||||||
CONF_GOTO_MAX,
|
CONF_GOTO_MAX,
|
||||||
CONF_GOTO_MIN,
|
CONF_GOTO_MIN,
|
||||||
CONF_GOTO_M1,
|
CONF_GOTO_M1,
|
||||||
CONF_GOTO_M2,
|
CONF_GOTO_M2,
|
||||||
CONF_GOTO_M3,
|
CONF_GOTO_M3,
|
||||||
CONF_GOTO_M4,
|
CONF_GOTO_M4,
|
||||||
CONF_SAVE_M1,
|
CONF_SAVE_M1,
|
||||||
CONF_SAVE_M2,
|
CONF_SAVE_M2,
|
||||||
CONF_SAVE_M3,
|
CONF_SAVE_M3,
|
||||||
CONF_SAVE_M4,
|
CONF_SAVE_M4,
|
||||||
]
|
]
|
||||||
|
|
||||||
MaidesiteDeskButton = maidesite_desk_ns.class_("MaidesiteDeskButton", button.Button, cg.Component)
|
MaidesiteDeskButton = maidesite_desk_ns.class_(
|
||||||
|
"MaidesiteDeskButton", button.Button, cg.Component
|
||||||
|
)
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
CONFIG_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_MAIDESITE_DESK_ID): cv.use_id(MaidesiteDeskComponent),
|
cv.GenerateID(CONF_MAIDESITE_DESK_ID): cv.use_id(MaidesiteDeskComponent),
|
||||||
|
cv.Optional(CONF_STEP_UP): button.button_schema(
|
||||||
cv.Optional(CONF_STEP_UP): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
),
|
||||||
),
|
cv.Optional(CONF_STEP_DOWN): button.button_schema(
|
||||||
cv.Optional(CONF_STEP_DOWN): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
),
|
||||||
),
|
cv.Optional(CONF_STOP): button.button_schema(
|
||||||
cv.Optional(CONF_STOP): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
),
|
||||||
),
|
cv.Optional(CONF_GOTO_MAX): button.button_schema(
|
||||||
cv.Optional(CONF_GOTO_MAX): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
),
|
||||||
),
|
cv.Optional(CONF_GOTO_MIN): button.button_schema(
|
||||||
cv.Optional(CONF_GOTO_MIN): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
),
|
||||||
),
|
cv.Optional(CONF_GOTO_M1): button.button_schema(
|
||||||
cv.Optional(CONF_GOTO_M1): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
),
|
||||||
),
|
cv.Optional(CONF_GOTO_M2): button.button_schema(
|
||||||
cv.Optional(CONF_GOTO_M2): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
),
|
||||||
),
|
cv.Optional(CONF_GOTO_M3): button.button_schema(
|
||||||
cv.Optional(CONF_GOTO_M3): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
),
|
||||||
),
|
cv.Optional(CONF_GOTO_M4): button.button_schema(
|
||||||
cv.Optional(CONF_GOTO_M4): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
),
|
||||||
),
|
cv.Optional(CONF_SAVE_M1): button.button_schema(
|
||||||
cv.Optional(CONF_SAVE_M1): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
),
|
||||||
),
|
cv.Optional(CONF_SAVE_M2): button.button_schema(
|
||||||
cv.Optional(CONF_SAVE_M2): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
),
|
||||||
),
|
cv.Optional(CONF_SAVE_M3): button.button_schema(
|
||||||
cv.Optional(CONF_SAVE_M3): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
),
|
||||||
),
|
cv.Optional(CONF_SAVE_M4): button.button_schema(
|
||||||
cv.Optional(CONF_SAVE_M4): button.button_schema(
|
MaidesiteDeskButton,
|
||||||
MaidesiteDeskButton,
|
entity_category=ENTITY_CATEGORY_CONFIG,
|
||||||
entity_category=ENTITY_CATEGORY_CONFIG,
|
),
|
||||||
),
|
}
|
||||||
}
|
|
||||||
).extend(cv.COMPONENT_SCHEMA)
|
).extend(cv.COMPONENT_SCHEMA)
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
hub = await cg.get_variable(config[CONF_MAIDESITE_DESK_ID])
|
hub = await cg.get_variable(config[CONF_MAIDESITE_DESK_ID])
|
||||||
for index, key in enumerate(TYPES):
|
for index, key in enumerate(TYPES):
|
||||||
if child_config := config.get(key):
|
if child_config := config.get(key):
|
||||||
var = await button.new_button(child_config)
|
var = await button.new_button(child_config)
|
||||||
await cg.register_component(var, child_config)
|
await cg.register_component(var, child_config)
|
||||||
await cg.register_parented(var, config[CONF_MAIDESITE_DESK_ID])
|
await cg.register_parented(var, config[CONF_MAIDESITE_DESK_ID])
|
||||||
cg.add(getattr(hub, f"set_{key}_button")(var))
|
cg.add(getattr(hub, f"set_{key}_button")(var))
|
||||||
cg.add(var.set_id(index))
|
cg.add(var.set_id(index))
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,17 @@
|
||||||
#include "maidesite_desk_button.h"
|
#include "maidesite_desk_button.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace maidesite_desk {
|
||||||
|
static const char* const TAG = "maidesite_desk.button";
|
||||||
|
|
||||||
namespace esphome
|
void MaidesiteDeskButton::dump_config() {
|
||||||
{
|
LOG_BUTTON("", "Maidesite Desk Button", this);
|
||||||
namespace maidesite_desk
|
delay(10);
|
||||||
{
|
}
|
||||||
static const char *const TAG = "maidesite_desk.button";
|
|
||||||
|
|
||||||
void MaidesiteDeskButton::dump_config()
|
void MaidesiteDeskButton::press_action() {
|
||||||
{
|
this->parent_->button_press_action(this);
|
||||||
LOG_BUTTON("", "Maidesite Desk Button", this);
|
}
|
||||||
delay(10);
|
} // namespace maidesite_desk
|
||||||
}
|
} // namespace esphome
|
||||||
|
|
||||||
void MaidesiteDeskButton::press_action()
|
|
||||||
{
|
|
||||||
this->parent_->button_press_action(this);
|
|
||||||
}
|
|
||||||
} // namespace maidesite_desk
|
|
||||||
} // namespace esphome
|
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,19 @@
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
#include "../maidesite_desk.h"
|
#include "../maidesite_desk.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace maidesite_desk {
|
||||||
|
class MaidesiteDeskButton : public button::Button, public Component, public Parented<MaidesiteDeskComponent> {
|
||||||
|
public:
|
||||||
|
MaidesiteDeskButton() = default;
|
||||||
|
void dump_config() override;
|
||||||
|
void set_id(int id) {
|
||||||
|
this->id_ = id;
|
||||||
|
}
|
||||||
|
|
||||||
namespace esphome
|
protected:
|
||||||
{
|
void press_action() override;
|
||||||
namespace maidesite_desk
|
int id_;
|
||||||
{
|
};
|
||||||
class MaidesiteDeskButton : public button::Button, public Component, public Parented<MaidesiteDeskComponent>
|
} // namespace maidesite_desk
|
||||||
{
|
} // namespace esphome
|
||||||
public:
|
|
||||||
MaidesiteDeskButton() = default;
|
|
||||||
void dump_config() override;
|
|
||||||
void set_id(int id) { this->id_ = id; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void press_action() override;
|
|
||||||
int id_;
|
|
||||||
};
|
|
||||||
} // namespace maidesite_desk
|
|
||||||
} // namespace esphome
|
|
||||||
|
|
|
||||||
|
|
@ -1,397 +1,359 @@
|
||||||
#include "maidesite_desk.h"
|
#include "maidesite_desk.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace maidesite_desk {
|
||||||
|
static const char* const TAG = "maidesite_desk";
|
||||||
|
|
||||||
namespace esphome
|
void MaidesiteDeskComponent::dump_config() {
|
||||||
{
|
ESP_LOGCONFIG(TAG, "Maidesite Desk");
|
||||||
namespace maidesite_desk
|
delay(10);
|
||||||
{
|
}
|
||||||
static const char *const TAG = "maidesite_desk";
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::dump_config()
|
void MaidesiteDeskComponent::setup() {
|
||||||
{
|
ESP_LOGCONFIG(TAG, "Setting up Maidesite Desk ...");
|
||||||
ESP_LOGCONFIG(TAG, "Maidesite Desk");
|
delay(10);
|
||||||
|
this->check_uart_settings(9600);
|
||||||
|
this->request_physical_limits();
|
||||||
|
this->request_limits();
|
||||||
|
this->request_settings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::loop() {
|
||||||
|
// This is a very simple method of receiving messages from the desk.
|
||||||
|
// It will fail on messages that contain the value 0x7E in their payload.
|
||||||
|
// But it is super simple and works for the messages we care about.
|
||||||
|
// Read message:
|
||||||
|
// format: 0xF2 0xF2 [command] [param_count] [[param] ...] [checksum] 0x7E
|
||||||
|
// checksum: sum of [command], [param_count] and all [param]s
|
||||||
|
|
||||||
|
uint8_t oneByte;
|
||||||
|
while (this->available()) {
|
||||||
|
this->read_byte(&oneByte);
|
||||||
|
|
||||||
|
// Message shall start with 0xF2, if not skip this byte
|
||||||
|
if (!this->response_receiving_) {
|
||||||
|
if (oneByte != 0xF2)
|
||||||
|
continue;
|
||||||
|
this->response_receiving_ = true;
|
||||||
|
}
|
||||||
|
// Add current byte to message buffer
|
||||||
|
this->response_message_.push_back(oneByte);
|
||||||
|
|
||||||
|
// Discard message if 2. byte is not 0xF2
|
||||||
|
if (this->response_message_.size() == 2 && oneByte != 0xF2) {
|
||||||
|
ESP_LOGW(TAG, "Invalid response message: 2. byte is 0x%02X but expexted is 0xF2", oneByte);
|
||||||
delay(10);
|
delay(10);
|
||||||
|
this->response_message_.clear();
|
||||||
|
this->response_receiving_ = false;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
// Discard message if it is too long
|
||||||
void MaidesiteDeskComponent::setup()
|
if (this->response_message_.size() > 10) {
|
||||||
{
|
ESP_LOGW(TAG, "Response message too long: expected not more than 10 bytes");
|
||||||
ESP_LOGCONFIG(TAG, "Setting up Maidesite Desk ...");
|
|
||||||
delay(10);
|
delay(10);
|
||||||
this->check_uart_settings(9600);
|
this->response_message_.clear();
|
||||||
this->request_physical_limits();
|
this->response_receiving_ = false;
|
||||||
this->request_limits();
|
continue;
|
||||||
this->request_settings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaidesiteDeskComponent::loop()
|
// Decode message if message is complete (last byte shall be 0x7E)
|
||||||
{
|
if (oneByte == 0x7E) {
|
||||||
// This is a very simple method of receiving messages from the desk.
|
this->log_uart_hex("<<<", this->response_message_, ',');
|
||||||
// It will fail on messages that contain the value 0x7E in their payload.
|
this->decode_response(this->response_message_);
|
||||||
// But it is super simple and works for the messages we care about.
|
this->response_message_.clear();
|
||||||
// Read message:
|
this->response_receiving_ = false;
|
||||||
// format: 0xF2 0xF2 [command] [param_count] [[param] ...] [checksum] 0x7E
|
|
||||||
// checksum: sum of [command], [param_count] and all [param]s
|
|
||||||
|
|
||||||
uint8_t oneByte;
|
|
||||||
while (this->available())
|
|
||||||
{
|
|
||||||
this->read_byte(&oneByte);
|
|
||||||
|
|
||||||
// Message shall start with 0xF2, if not skip this byte
|
|
||||||
if (!this->response_receiving_)
|
|
||||||
{
|
|
||||||
if (oneByte != 0xF2)
|
|
||||||
continue;
|
|
||||||
this->response_receiving_ = true;
|
|
||||||
}
|
|
||||||
// Add current byte to message buffer
|
|
||||||
this->response_message_.push_back(oneByte);
|
|
||||||
|
|
||||||
// Discard message if 2. byte is not 0xF2
|
|
||||||
if (this->response_message_.size() == 2 && oneByte != 0xF2)
|
|
||||||
{
|
|
||||||
ESP_LOGW(TAG, "Invalid response message: 2. byte is 0x%02X but expexted is 0xF2", oneByte);
|
|
||||||
delay(10);
|
|
||||||
this->response_message_.clear();
|
|
||||||
this->response_receiving_ = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Discard message if it is too long
|
|
||||||
if (this->response_message_.size() > 10)
|
|
||||||
{
|
|
||||||
ESP_LOGW(TAG, "Response message too long: expected not more than 10 bytes");
|
|
||||||
delay(10);
|
|
||||||
this->response_message_.clear();
|
|
||||||
this->response_receiving_ = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode message if message is complete (last byte shall be 0x7E)
|
|
||||||
if (oneByte == 0x7E)
|
|
||||||
{
|
|
||||||
this->log_uart_hex("<<<", this->response_message_, ',');
|
|
||||||
this->decode_response(this->response_message_);
|
|
||||||
this->response_message_.clear();
|
|
||||||
this->response_receiving_ = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MaidesiteDeskComponent::log_uart_hex(std::string prefix, std::vector<uint8_t> bytes, uint8_t separator)
|
void MaidesiteDeskComponent::log_uart_hex(std::string prefix, std::vector<uint8_t> bytes, uint8_t separator) {
|
||||||
{
|
if (this->log_uart_msg_ == false)
|
||||||
if (this->log_uart_msg_ == false) return;
|
return;
|
||||||
|
|
||||||
std::string logStr;
|
std::string logStr;
|
||||||
char buffer[5];
|
char buffer[5];
|
||||||
|
|
||||||
for (size_t i = 0; i < bytes.size(); i++)
|
for (size_t i = 0; i < bytes.size(); i++) {
|
||||||
{
|
if (i > 0)
|
||||||
if (i > 0) logStr += separator;
|
logStr += separator;
|
||||||
sprintf(buffer, "%02X", bytes[i]);
|
sprintf(buffer, "%02X", bytes[i]);
|
||||||
logStr += buffer;
|
logStr += buffer;
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < logStr.length(); i += UART_LOG_CHUNK_SIZE)
|
for (size_t i = 0; i < logStr.length(); i += UART_LOG_CHUNK_SIZE) {
|
||||||
{
|
ESP_LOGI(TAG, "%s %s", prefix.c_str(), logStr.substr(i, UART_LOG_CHUNK_SIZE).c_str());
|
||||||
ESP_LOGI(TAG, "%s %s", prefix.c_str(), logStr.substr(i, UART_LOG_CHUNK_SIZE).c_str());
|
delay(10);
|
||||||
delay(10);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::decode_response(std::vector<uint8_t> message) {
|
||||||
|
// ToDo: Add checksum check
|
||||||
|
|
||||||
|
switch (message[2]) {
|
||||||
|
case 0x01:
|
||||||
|
ESP_LOGI(TAG, "Set height to 0x%0X%0X", message[4], message[5]);
|
||||||
|
delay(10);
|
||||||
|
|
||||||
|
float new_height;
|
||||||
|
new_height = byte2float(message[4], message[5]);
|
||||||
|
if (new_height == this->current_height_)
|
||||||
|
return;
|
||||||
|
this->current_height_ = new_height;
|
||||||
|
if (this->height_abs_sensor_ != nullptr)
|
||||||
|
this->height_abs_sensor_->publish_state(this->current_height_);
|
||||||
|
if (this->height_abs_number_ != nullptr)
|
||||||
|
this->height_abs_number_->publish_state(this->current_height_);
|
||||||
|
|
||||||
|
if (this->height_pct_sensor_ != nullptr && limit_max_ != 0)
|
||||||
|
this->height_pct_sensor_->publish_state((this->current_height_ - this->limit_min_) /
|
||||||
|
(this->limit_max_ - this->limit_min_) * 100);
|
||||||
|
if (this->height_pct_number_ != nullptr && limit_max_ != 0)
|
||||||
|
this->height_pct_number_->publish_state(
|
||||||
|
roundf((this->current_height_ - this->limit_min_) / (this->limit_max_ - this->limit_min_) * 1000) / 10);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x20:
|
||||||
|
ESP_LOGI(TAG, "Set limits to 0x%0X max=%i min=%i", message[4], (message[5] & 1), (message[4] >> 4));
|
||||||
|
delay(10);
|
||||||
|
|
||||||
|
if ((message[4] & 1) == 0) { // low nibble 0 -> no max limit, use physical_max_
|
||||||
|
this->limit_max_ = this->physical_max_;
|
||||||
|
if (this->height_max_sensor_ != nullptr)
|
||||||
|
this->height_max_sensor_->publish_state(this->limit_max_);
|
||||||
|
if (height_abs_number_ != nullptr)
|
||||||
|
this->height_abs_number_->traits.set_max_value(this->limit_max_);
|
||||||
}
|
}
|
||||||
|
if ((message[4] >> 4) == 0) { // high nibble 0 -> no min limit, use physical_min_
|
||||||
void MaidesiteDeskComponent::decode_response(std::vector<uint8_t> message)
|
this->limit_min_ = this->physical_min_;
|
||||||
{
|
if (this->height_min_sensor_ != nullptr)
|
||||||
// ToDo: Add checksum check
|
this->height_min_sensor_->publish_state(limit_min_);
|
||||||
|
if (height_abs_number_ != nullptr)
|
||||||
switch (message[2])
|
this->height_abs_number_->traits.set_min_value(limit_min_);
|
||||||
{
|
|
||||||
case 0x01:
|
|
||||||
ESP_LOGI(TAG, "Set height to 0x%0X%0X", message[4], message[5]);
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
float new_height;
|
|
||||||
new_height = byte2float(message[4], message[5]);
|
|
||||||
if (new_height == this->current_height_)
|
|
||||||
return;
|
|
||||||
this->current_height_ = new_height;
|
|
||||||
if (this->height_abs_sensor_ != nullptr)
|
|
||||||
this->height_abs_sensor_->publish_state(this->current_height_);
|
|
||||||
if (this->height_abs_number_ != nullptr)
|
|
||||||
this->height_abs_number_->publish_state(this->current_height_);
|
|
||||||
|
|
||||||
if (this->height_pct_sensor_ != nullptr && limit_max_ != 0)
|
|
||||||
this->height_pct_sensor_->publish_state((this->current_height_ - this->limit_min_) / (this->limit_max_ - this->limit_min_) * 100);
|
|
||||||
if (this->height_pct_number_ != nullptr && limit_max_ != 0)
|
|
||||||
this->height_pct_number_->publish_state(roundf((this->current_height_ - this->limit_min_) / (this->limit_max_ - this->limit_min_) * 1000) / 10);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x20:
|
|
||||||
ESP_LOGI(TAG, "Set limits to 0x%0X max=%i min=%i", message[4], (message[5] & 1), (message[4] >> 4));
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
if ((message[4] & 1) == 0)
|
|
||||||
{ // low nibble 0 -> no max limit, use physical_max_
|
|
||||||
this->limit_max_ = this->physical_max_;
|
|
||||||
if (this->height_max_sensor_ != nullptr)
|
|
||||||
this->height_max_sensor_->publish_state(this->limit_max_);
|
|
||||||
if (height_abs_number_ != nullptr)
|
|
||||||
this->height_abs_number_->traits.set_max_value(this->limit_max_);
|
|
||||||
}
|
|
||||||
if ((message[4] >> 4) == 0)
|
|
||||||
{ // high nibble 0 -> no min limit, use physical_min_
|
|
||||||
this->limit_min_ = this->physical_min_;
|
|
||||||
if (this->height_min_sensor_ != nullptr)
|
|
||||||
this->height_min_sensor_->publish_state(limit_min_);
|
|
||||||
if (height_abs_number_ != nullptr)
|
|
||||||
this->height_abs_number_->traits.set_min_value(limit_min_);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x07:
|
|
||||||
ESP_LOGI(TAG, "Set physical limits to min=0x%02X%02X max=0x%02X%02X", message[4], message[5], message[6], message[7]);
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
this->physical_max_ = this->byte2float(message[4], message[5]);
|
|
||||||
this->physical_min_ = this->byte2float(message[6], message[7]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x21:
|
|
||||||
ESP_LOGI(TAG, "Set max. height to 0x%02X%02X", message[4], message[5]);
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
this->limit_max_ = this->byte2float(message[4], message[5]);
|
|
||||||
if (this->height_max_sensor_ != nullptr)
|
|
||||||
this->height_max_sensor_->publish_state(limit_max_);
|
|
||||||
if (height_abs_number_ != nullptr)
|
|
||||||
this->height_abs_number_->traits.set_max_value(limit_max_);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x22:
|
|
||||||
ESP_LOGI(TAG, "Set min. height to 0x%02X%02X", message[4], message[5]);
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
this->limit_min_ = this->byte2float(message[4], message[5]);
|
|
||||||
if (this->height_min_sensor_ != nullptr)
|
|
||||||
this->height_min_sensor_->publish_state(limit_min_);
|
|
||||||
if (height_abs_number_ != nullptr)
|
|
||||||
this->height_abs_number_->traits.set_min_value(limit_min_);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x25:
|
|
||||||
ESP_LOGI(TAG, "Set position m1 to 0x%02X%02X", message[4], message[5]);
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
if (this->position_m1_sensor_ != nullptr)
|
|
||||||
this->position_m1_sensor_->publish_state(this->byte2float(message[4], message[5]));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x26:
|
|
||||||
ESP_LOGI(TAG, "Set position m2 to 0x%02X%02X", message[4], message[5]);
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
if (this->position_m2_sensor_ != nullptr)
|
|
||||||
this->position_m2_sensor_->publish_state(this->byte2float(message[4], message[5]));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x27:
|
|
||||||
ESP_LOGI(TAG, "Set position m3 to 0x%02X%02X", message[4], message[5]);
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
if (this->position_m3_sensor_ != nullptr)
|
|
||||||
this->position_m3_sensor_->publish_state(this->byte2float(message[4], message[5]));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x28:
|
|
||||||
ESP_LOGI(TAG, "Set position m4 to 0x%02X%02X", message[4], message[5]);
|
|
||||||
delay(10);
|
|
||||||
|
|
||||||
if (this->position_m4_sensor_ != nullptr)
|
|
||||||
this->position_m4_sensor_->publish_state(this->byte2float(message[4], message[5]));
|
|
||||||
break;
|
|
||||||
|
|
||||||
// case 0x0E:
|
|
||||||
// ESP_LOGI(TAG, "units 0x%02X", message[4]);
|
|
||||||
// if (units != nullptr)
|
|
||||||
// units->publish_state(byte2float(message[4], message[5]));
|
|
||||||
// break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
ESP_LOGI(TAG, "Received unknown message");
|
|
||||||
delay(10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
float MaidesiteDeskComponent::byte2float(int high, int low)
|
case 0x07:
|
||||||
{
|
ESP_LOGI(TAG, "Set physical limits to min=0x%02X%02X max=0x%02X%02X", message[4], message[5], message[6],
|
||||||
return static_cast<float>((high << 8) + low) / 10;
|
message[7]);
|
||||||
}
|
delay(10);
|
||||||
|
|
||||||
// Write message:
|
this->physical_max_ = this->byte2float(message[4], message[5]);
|
||||||
// format: 0xF1 0xF1 [command] [param_count] [[param] ...] [checksum] 0x7E
|
this->physical_min_ = this->byte2float(message[6], message[7]);
|
||||||
// checksum: sum of [command], [param_count] and all [param]s
|
break;
|
||||||
void MaidesiteDeskComponent::send_simple_command(unsigned char cmd)
|
|
||||||
{
|
|
||||||
this->request_message_.clear();
|
|
||||||
this->request_message_.insert(this->request_message_.end(), { 0xF1, 0xF1, cmd, 0x00, cmd, 0x7E });
|
|
||||||
this->write_array(this->request_message_);
|
|
||||||
this->log_uart_hex(">>>", this->request_message_, ',');
|
|
||||||
delay(100); // NOLINT
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::send_2byte_command(unsigned char cmd, unsigned char high_byte, unsigned char low_byte)
|
case 0x21:
|
||||||
{
|
ESP_LOGI(TAG, "Set max. height to 0x%02X%02X", message[4], message[5]);
|
||||||
// ToDo: make one function of send_simple_command and send_2byte_command
|
delay(10);
|
||||||
|
|
||||||
unsigned char checksum = cmd + 2 + high_byte + low_byte;
|
this->limit_max_ = this->byte2float(message[4], message[5]);
|
||||||
this->request_message_.clear();
|
if (this->height_max_sensor_ != nullptr)
|
||||||
this->request_message_.insert(this->request_message_.end(), { 0xF1, 0xF1, cmd, 0x02, high_byte, low_byte, checksum, 0x7E });
|
this->height_max_sensor_->publish_state(limit_max_);
|
||||||
this->write_array(this->request_message_);
|
if (height_abs_number_ != nullptr)
|
||||||
this->log_uart_hex(">>>", this->request_message_, ',');
|
this->height_abs_number_->traits.set_max_value(limit_max_);
|
||||||
delay(100); // NOLINT
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::step_up()
|
case 0x22:
|
||||||
{
|
ESP_LOGI(TAG, "Set min. height to 0x%02X%02X", message[4], message[5]);
|
||||||
this->send_simple_command(0x01);
|
delay(10);
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::step_down()
|
this->limit_min_ = this->byte2float(message[4], message[5]);
|
||||||
{
|
if (this->height_min_sensor_ != nullptr)
|
||||||
this->send_simple_command(0x02);
|
this->height_min_sensor_->publish_state(limit_min_);
|
||||||
}
|
if (height_abs_number_ != nullptr)
|
||||||
|
this->height_abs_number_->traits.set_min_value(limit_min_);
|
||||||
|
break;
|
||||||
|
|
||||||
void MaidesiteDeskComponent::stop()
|
case 0x25:
|
||||||
{
|
ESP_LOGI(TAG, "Set position m1 to 0x%02X%02X", message[4], message[5]);
|
||||||
this->send_simple_command(0x2B);
|
delay(10);
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::goto_mem_position(int pos)
|
if (this->position_m1_sensor_ != nullptr)
|
||||||
{
|
this->position_m1_sensor_->publish_state(this->byte2float(message[4], message[5]));
|
||||||
switch (pos)
|
break;
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
this->send_simple_command(0x05);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
this->send_simple_command(0x06);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
this->send_simple_command(0x27);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
this->send_simple_command(0x28);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::save_mem_position(int pos)
|
case 0x26:
|
||||||
{
|
ESP_LOGI(TAG, "Set position m2 to 0x%02X%02X", message[4], message[5]);
|
||||||
switch (pos)
|
delay(10);
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
this->send_simple_command(0x03);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
this->send_simple_command(0x04);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
this->send_simple_command(0x25);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
this->send_simple_command(0x26);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::request_physical_limits()
|
if (this->position_m2_sensor_ != nullptr)
|
||||||
{
|
this->position_m2_sensor_->publish_state(this->byte2float(message[4], message[5]));
|
||||||
this->send_simple_command(0x0C);
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::request_limits()
|
case 0x27:
|
||||||
{
|
ESP_LOGI(TAG, "Set position m3 to 0x%02X%02X", message[4], message[5]);
|
||||||
this->send_simple_command(0x20);
|
delay(10);
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::request_settings()
|
if (this->position_m3_sensor_ != nullptr)
|
||||||
{
|
this->position_m3_sensor_->publish_state(this->byte2float(message[4], message[5]));
|
||||||
this->send_simple_command(0x07);
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::request_move_to()
|
case 0x28:
|
||||||
{
|
ESP_LOGI(TAG, "Set position m4 to 0x%02X%02X", message[4], message[5]);
|
||||||
this->send_simple_command(0x1B);
|
delay(10);
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::goto_max_position()
|
if (this->position_m4_sensor_ != nullptr)
|
||||||
{
|
this->position_m4_sensor_->publish_state(this->byte2float(message[4], message[5]));
|
||||||
this->goto_height(limit_max_);
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
void MaidesiteDeskComponent::goto_min_position()
|
// case 0x0E:
|
||||||
{
|
// ESP_LOGI(TAG, "units 0x%02X", message[4]);
|
||||||
this->goto_height(limit_min_);
|
// if (units != nullptr)
|
||||||
}
|
// units->publish_state(byte2float(message[4], message[5]));
|
||||||
|
// break;
|
||||||
|
|
||||||
void MaidesiteDeskComponent::goto_height(float height)
|
default:
|
||||||
{
|
ESP_LOGI(TAG, "Received unknown message");
|
||||||
unsigned char high_byte = ((int)height * 10) >> 8;
|
delay(10);
|
||||||
unsigned char low_byte = ((int)height * 10) & 0xFF;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->send_2byte_command(0x80, high_byte, low_byte);
|
float MaidesiteDeskComponent::byte2float(int high, int low) {
|
||||||
this->request_move_to();
|
return static_cast<float>((high << 8) + low) / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write message:
|
||||||
|
// format: 0xF1 0xF1 [command] [param_count] [[param] ...] [checksum] 0x7E
|
||||||
|
// checksum: sum of [command], [param_count] and all [param]s
|
||||||
|
void MaidesiteDeskComponent::send_simple_command(unsigned char cmd) {
|
||||||
|
this->request_message_.clear();
|
||||||
|
this->request_message_.insert(this->request_message_.end(), {0xF1, 0xF1, cmd, 0x00, cmd, 0x7E});
|
||||||
|
this->write_array(this->request_message_);
|
||||||
|
this->log_uart_hex(">>>", this->request_message_, ',');
|
||||||
|
delay(100); // NOLINT
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::send_2byte_command(unsigned char cmd, unsigned char high_byte, unsigned char low_byte) {
|
||||||
|
// ToDo: make one function of send_simple_command and send_2byte_command
|
||||||
|
|
||||||
|
unsigned char checksum = cmd + 2 + high_byte + low_byte;
|
||||||
|
this->request_message_.clear();
|
||||||
|
this->request_message_.insert(this->request_message_.end(),
|
||||||
|
{0xF1, 0xF1, cmd, 0x02, high_byte, low_byte, checksum, 0x7E});
|
||||||
|
this->write_array(this->request_message_);
|
||||||
|
this->log_uart_hex(">>>", this->request_message_, ',');
|
||||||
|
delay(100); // NOLINT
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::step_up() {
|
||||||
|
this->send_simple_command(0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::step_down() {
|
||||||
|
this->send_simple_command(0x02);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::stop() {
|
||||||
|
this->send_simple_command(0x2B);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::goto_mem_position(int pos) {
|
||||||
|
switch (pos) {
|
||||||
|
case 1:
|
||||||
|
this->send_simple_command(0x05);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
this->send_simple_command(0x06);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
this->send_simple_command(0x27);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
this->send_simple_command(0x28);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::save_mem_position(int pos) {
|
||||||
|
switch (pos) {
|
||||||
|
case 1:
|
||||||
|
this->send_simple_command(0x03);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
this->send_simple_command(0x04);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
this->send_simple_command(0x25);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
this->send_simple_command(0x26);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::request_physical_limits() {
|
||||||
|
this->send_simple_command(0x0C);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::request_limits() {
|
||||||
|
this->send_simple_command(0x20);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::request_settings() {
|
||||||
|
this->send_simple_command(0x07);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::request_move_to() {
|
||||||
|
this->send_simple_command(0x1B);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::goto_max_position() {
|
||||||
|
this->goto_height(limit_max_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::goto_min_position() {
|
||||||
|
this->goto_height(limit_min_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaidesiteDeskComponent::goto_height(float height) {
|
||||||
|
unsigned char high_byte = ((int)height * 10) >> 8;
|
||||||
|
unsigned char low_byte = ((int)height * 10) & 0xFF;
|
||||||
|
|
||||||
|
this->send_2byte_command(0x80, high_byte, low_byte);
|
||||||
|
this->request_move_to();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_BUTTON
|
#ifdef USE_BUTTON
|
||||||
void MaidesiteDeskComponent::button_press_action(button::Button* object)
|
void MaidesiteDeskComponent::button_press_action(button::Button* object) {
|
||||||
{
|
if (object == step_up_button_)
|
||||||
if (object == step_up_button_)
|
this->step_up();
|
||||||
this->step_up();
|
else if (object == step_down_button_)
|
||||||
else if (object == step_down_button_)
|
this->step_down();
|
||||||
this->step_down();
|
else if (object == stop_button_)
|
||||||
else if (object == stop_button_)
|
this->stop();
|
||||||
this->stop();
|
else if (object == goto_max_button_)
|
||||||
else if (object == goto_max_button_)
|
this->goto_max_position();
|
||||||
this->goto_max_position();
|
else if (object == goto_min_button_)
|
||||||
else if (object == goto_min_button_)
|
this->goto_min_position();
|
||||||
this->goto_min_position();
|
else if (object == goto_m1_button_)
|
||||||
else if (object == goto_m1_button_)
|
this->goto_mem_position(1);
|
||||||
this->goto_mem_position(1);
|
else if (object == goto_m2_button_)
|
||||||
else if (object == goto_m2_button_)
|
this->goto_mem_position(2);
|
||||||
this->goto_mem_position(2);
|
else if (object == goto_m3_button_)
|
||||||
else if (object == goto_m3_button_)
|
this->goto_mem_position(3);
|
||||||
this->goto_mem_position(3);
|
else if (object == goto_m4_button_)
|
||||||
else if (object == goto_m4_button_)
|
this->goto_mem_position(4);
|
||||||
this->goto_mem_position(4);
|
else if (object == save_m1_button_) {
|
||||||
else if (object == save_m1_button_)
|
this->save_mem_position(1);
|
||||||
{
|
this->request_settings();
|
||||||
this->save_mem_position(1);
|
} else if (object == save_m2_button_) {
|
||||||
this->request_settings();
|
this->save_mem_position(2);
|
||||||
}
|
this->request_settings();
|
||||||
else if (object == save_m2_button_)
|
} else if (object == save_m3_button_) {
|
||||||
{
|
this->save_mem_position(3);
|
||||||
this->save_mem_position(2);
|
this->request_settings();
|
||||||
this->request_settings();
|
} else if (object == save_m4_button_) {
|
||||||
}
|
this->save_mem_position(4);
|
||||||
else if (object == save_m3_button_)
|
this->request_settings();
|
||||||
{
|
}
|
||||||
this->save_mem_position(3);
|
}
|
||||||
this->request_settings();
|
|
||||||
}
|
|
||||||
else if (object == save_m4_button_)
|
|
||||||
{
|
|
||||||
this->save_mem_position(4);
|
|
||||||
this->request_settings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_NUMBER
|
#ifdef USE_NUMBER
|
||||||
void MaidesiteDeskComponent::number_control(number::Number* object, float value)
|
void MaidesiteDeskComponent::number_control(number::Number* object, float value) {
|
||||||
{
|
if (object == height_abs_number_)
|
||||||
if (object == height_abs_number_)
|
this->goto_height(value);
|
||||||
this->goto_height(value);
|
else if (object == height_pct_number_)
|
||||||
else if (object == height_pct_number_)
|
if (limit_max_ > 0 && limit_max_ > limit_min_)
|
||||||
if (limit_max_ > 0 && limit_max_ > limit_min_)
|
this->goto_height((limit_max_ - limit_min_) * value / 100 + limit_min_);
|
||||||
this->goto_height((limit_max_ - limit_min_) * value / 100 + limit_min_);
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
} // namespace maidesite_desk
|
} // namespace maidesite_desk
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
|
||||||
|
|
@ -17,98 +17,98 @@
|
||||||
|
|
||||||
#define UART_LOG_CHUNK_SIZE 153
|
#define UART_LOG_CHUNK_SIZE 153
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace maidesite_desk {
|
||||||
|
|
||||||
namespace esphome
|
class MaidesiteDeskComponent : public Component, public uart::UARTDevice {
|
||||||
{
|
public:
|
||||||
namespace maidesite_desk
|
|
||||||
{
|
|
||||||
|
|
||||||
class MaidesiteDeskComponent : public Component, public uart::UARTDevice
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
#ifdef USE_SENSOR
|
#ifdef USE_SENSOR
|
||||||
SUB_SENSOR(unit);
|
SUB_SENSOR(unit);
|
||||||
SUB_SENSOR(height_abs);
|
SUB_SENSOR(height_abs);
|
||||||
SUB_SENSOR(height_pct);
|
SUB_SENSOR(height_pct);
|
||||||
SUB_SENSOR(height_min);
|
SUB_SENSOR(height_min);
|
||||||
SUB_SENSOR(height_max);
|
SUB_SENSOR(height_max);
|
||||||
SUB_SENSOR(position_m1);
|
SUB_SENSOR(position_m1);
|
||||||
SUB_SENSOR(position_m2);
|
SUB_SENSOR(position_m2);
|
||||||
SUB_SENSOR(position_m3);
|
SUB_SENSOR(position_m3);
|
||||||
SUB_SENSOR(position_m4);
|
SUB_SENSOR(position_m4);
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_BUTTON
|
#ifdef USE_BUTTON
|
||||||
SUB_BUTTON(unit);
|
SUB_BUTTON(unit);
|
||||||
SUB_BUTTON(step_up);
|
SUB_BUTTON(step_up);
|
||||||
SUB_BUTTON(step_down);
|
SUB_BUTTON(step_down);
|
||||||
SUB_BUTTON(stop);
|
SUB_BUTTON(stop);
|
||||||
SUB_BUTTON(goto_max);
|
SUB_BUTTON(goto_max);
|
||||||
SUB_BUTTON(goto_min);
|
SUB_BUTTON(goto_min);
|
||||||
SUB_BUTTON(goto_m1);
|
SUB_BUTTON(goto_m1);
|
||||||
SUB_BUTTON(goto_m2);
|
SUB_BUTTON(goto_m2);
|
||||||
SUB_BUTTON(goto_m3);
|
SUB_BUTTON(goto_m3);
|
||||||
SUB_BUTTON(goto_m4);
|
SUB_BUTTON(goto_m4);
|
||||||
SUB_BUTTON(save_m1);
|
SUB_BUTTON(save_m1);
|
||||||
SUB_BUTTON(save_m2);
|
SUB_BUTTON(save_m2);
|
||||||
SUB_BUTTON(save_m3);
|
SUB_BUTTON(save_m3);
|
||||||
SUB_BUTTON(save_m4);
|
SUB_BUTTON(save_m4);
|
||||||
|
|
||||||
void button_press_action(button::Button* object);
|
void button_press_action(button::Button* object);
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_NUMBER
|
#ifdef USE_NUMBER
|
||||||
SUB_NUMBER(height_abs);
|
SUB_NUMBER(height_abs);
|
||||||
SUB_NUMBER(height_pct);
|
SUB_NUMBER(height_pct);
|
||||||
|
|
||||||
void number_control(number::Number* object, float value);
|
void number_control(number::Number* object, float value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MaidesiteDeskComponent() = default;
|
MaidesiteDeskComponent() = default;
|
||||||
// base class functions
|
// base class functions
|
||||||
float get_setup_priority() const override { return setup_priority::LATE; }
|
float get_setup_priority() const override {
|
||||||
void dump_config() override;
|
return setup_priority::LATE;
|
||||||
void setup() override;
|
}
|
||||||
void loop() override;
|
void dump_config() override;
|
||||||
// option functions
|
void setup() override;
|
||||||
void set_log_uart_msg(bool enable) { this->log_uart_msg_ = enable; }
|
void loop() override;
|
||||||
// functions to use in lambdas
|
// option functions
|
||||||
void request_physical_limits();
|
void set_log_uart_msg(bool enable) {
|
||||||
void request_limits();
|
this->log_uart_msg_ = enable;
|
||||||
void request_settings();
|
}
|
||||||
void request_move_to();
|
// functions to use in lambdas
|
||||||
void step_up();
|
void request_physical_limits();
|
||||||
void step_down();
|
void request_limits();
|
||||||
void stop();
|
void request_settings();
|
||||||
void goto_height(float height);
|
void request_move_to();
|
||||||
void goto_min_position();
|
void step_up();
|
||||||
void goto_max_position();
|
void step_down();
|
||||||
void goto_mem_position(int pos);
|
void stop();
|
||||||
void save_mem_position(int pos);
|
void goto_height(float height);
|
||||||
|
void goto_min_position();
|
||||||
|
void goto_max_position();
|
||||||
|
void goto_mem_position(int pos);
|
||||||
|
void save_mem_position(int pos);
|
||||||
|
|
||||||
// variables to use in lambdas
|
// variables to use in lambdas
|
||||||
std::vector<uint8_t> response_message_;
|
std::vector<uint8_t> response_message_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// uart message functions
|
// uart message functions
|
||||||
void decode_response(std::vector<uint8_t> message);
|
void decode_response(std::vector<uint8_t> message);
|
||||||
void send_simple_command(unsigned char cmd);
|
void send_simple_command(unsigned char cmd);
|
||||||
void send_2byte_command(unsigned char cmd, unsigned char high_byte, unsigned char low_byte);
|
void send_2byte_command(unsigned char cmd, unsigned char high_byte, unsigned char low_byte);
|
||||||
float byte2float(int high, int low);
|
float byte2float(int high, int low);
|
||||||
void log_uart_hex(std::string prefix, std::vector<uint8_t> bytes, uint8_t separator);
|
void log_uart_hex(std::string prefix, std::vector<uint8_t> bytes, uint8_t separator);
|
||||||
|
|
||||||
// options variables
|
// options variables
|
||||||
bool log_uart_msg_ { false };
|
bool log_uart_msg_{false};
|
||||||
// uart message variables
|
// uart message variables
|
||||||
std::vector<uint8_t> request_message_;
|
std::vector<uint8_t> request_message_;
|
||||||
uint8_t response_payload_length_;
|
uint8_t response_payload_length_;
|
||||||
uint8_t request_payload_length_;
|
uint8_t request_payload_length_;
|
||||||
bool response_receiving_ { false };
|
bool response_receiving_{false};
|
||||||
bool request_receiving_ { false };
|
bool request_receiving_{false};
|
||||||
// sensor variables
|
// sensor variables
|
||||||
float current_height_ = 0;
|
float current_height_ = 0;
|
||||||
float limit_min_ = 0;
|
float limit_min_ = 0;
|
||||||
float limit_max_ = 0;
|
float limit_max_ = 0;
|
||||||
float physical_min_ = 0;
|
float physical_min_ = 0;
|
||||||
float physical_max_ = 0;
|
float physical_max_ = 0;
|
||||||
};
|
};
|
||||||
} // namespace maidesite_desk
|
} // namespace maidesite_desk
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
|
||||||
|
|
@ -2,53 +2,62 @@ import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.components import number
|
from esphome.components import number
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
UNIT_CENTIMETER,
|
UNIT_CENTIMETER,
|
||||||
UNIT_PERCENT,
|
UNIT_PERCENT,
|
||||||
)
|
)
|
||||||
from .. import CONF_MAIDESITE_DESK_ID, MaidesiteDeskComponent, maidesite_desk_ns
|
from .. import CONF_MAIDESITE_DESK_ID, MaidesiteDeskComponent, maidesite_desk_ns
|
||||||
|
|
||||||
|
|
||||||
CONF_HEIGHT_ABS = "height_abs"
|
CONF_HEIGHT_ABS = "height_abs"
|
||||||
CONF_HEIGHT_PCT = "height_pct"
|
CONF_HEIGHT_PCT = "height_pct"
|
||||||
|
|
||||||
TYPES = [
|
TYPES = [
|
||||||
CONF_HEIGHT_ABS,
|
CONF_HEIGHT_ABS,
|
||||||
CONF_HEIGHT_PCT,
|
CONF_HEIGHT_PCT,
|
||||||
]
|
]
|
||||||
|
|
||||||
CONF_NUMBERS = [
|
CONF_NUMBERS = [
|
||||||
[ 0, 120, .2, ],
|
[
|
||||||
[ 0, 100, .1, ],
|
0,
|
||||||
|
120,
|
||||||
|
0.2,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
100,
|
||||||
|
0.1,
|
||||||
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
MaidesiteDeskNumber = maidesite_desk_ns.class_("MaidesiteDeskNumber", number.Number, cg.Component)
|
MaidesiteDeskNumber = maidesite_desk_ns.class_(
|
||||||
|
"MaidesiteDeskNumber", number.Number, cg.Component
|
||||||
|
)
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
CONFIG_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_MAIDESITE_DESK_ID): cv.use_id(MaidesiteDeskComponent),
|
cv.GenerateID(CONF_MAIDESITE_DESK_ID): cv.use_id(MaidesiteDeskComponent),
|
||||||
|
cv.Optional(CONF_HEIGHT_ABS): number.number_schema(
|
||||||
cv.Optional(CONF_HEIGHT_ABS): number.number_schema(
|
MaidesiteDeskNumber,
|
||||||
MaidesiteDeskNumber,
|
unit_of_measurement=UNIT_CENTIMETER,
|
||||||
unit_of_measurement=UNIT_CENTIMETER,
|
),
|
||||||
),
|
cv.Optional(CONF_HEIGHT_PCT): number.number_schema(
|
||||||
cv.Optional(CONF_HEIGHT_PCT): number.number_schema(
|
MaidesiteDeskNumber,
|
||||||
MaidesiteDeskNumber,
|
unit_of_measurement=UNIT_PERCENT,
|
||||||
unit_of_measurement=UNIT_PERCENT,
|
),
|
||||||
),
|
}
|
||||||
}
|
|
||||||
).extend(cv.COMPONENT_SCHEMA)
|
).extend(cv.COMPONENT_SCHEMA)
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
hub = await cg.get_variable(config[CONF_MAIDESITE_DESK_ID])
|
hub = await cg.get_variable(config[CONF_MAIDESITE_DESK_ID])
|
||||||
for index, key in enumerate(TYPES):
|
for index, key in enumerate(TYPES):
|
||||||
if child_config := config.get(key):
|
if child_config := config.get(key):
|
||||||
var = await number.new_number(
|
var = await number.new_number(
|
||||||
child_config,
|
child_config,
|
||||||
min_value=CONF_NUMBERS[index][0],
|
min_value=CONF_NUMBERS[index][0],
|
||||||
max_value=CONF_NUMBERS[index][1],
|
max_value=CONF_NUMBERS[index][1],
|
||||||
step=CONF_NUMBERS[index][2]
|
step=CONF_NUMBERS[index][2],
|
||||||
)
|
)
|
||||||
await cg.register_component(var, child_config)
|
await cg.register_component(var, child_config)
|
||||||
await cg.register_parented(var, config[CONF_MAIDESITE_DESK_ID])
|
await cg.register_parented(var, config[CONF_MAIDESITE_DESK_ID])
|
||||||
cg.add(getattr(hub, f"set_{key}_number")(var))
|
cg.add(getattr(hub, f"set_{key}_number")(var))
|
||||||
cg.add(var.set_id(index))
|
cg.add(var.set_id(index))
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,18 @@
|
||||||
#include "maidesite_desk_number.h"
|
#include "maidesite_desk_number.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace maidesite_desk {
|
||||||
|
static const char* const TAG = "maidesite_desk.number";
|
||||||
|
|
||||||
namespace esphome
|
void MaidesiteDeskNumber::dump_config() {
|
||||||
{
|
LOG_NUMBER("", "Maidesite Desk Number", this);
|
||||||
namespace maidesite_desk
|
delay(10);
|
||||||
{
|
}
|
||||||
static const char *const TAG = "maidesite_desk.number";
|
|
||||||
|
|
||||||
void MaidesiteDeskNumber::dump_config()
|
void MaidesiteDeskNumber::control(float value) {
|
||||||
{
|
this->publish_state(value);
|
||||||
LOG_NUMBER("", "Maidesite Desk Number", this);
|
this->parent_->number_control(this, value);
|
||||||
delay(10);
|
}
|
||||||
}
|
} // namespace maidesite_desk
|
||||||
|
} // namespace esphome
|
||||||
void MaidesiteDeskNumber::control(float value)
|
|
||||||
{
|
|
||||||
this->publish_state(value);
|
|
||||||
this->parent_->number_control(this, value);
|
|
||||||
}
|
|
||||||
} // namespace maidesite_desk
|
|
||||||
} // namespace esphome
|
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,19 @@
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
#include "../maidesite_desk.h"
|
#include "../maidesite_desk.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace maidesite_desk {
|
||||||
|
class MaidesiteDeskNumber : public number::Number, public Component, public Parented<MaidesiteDeskComponent> {
|
||||||
|
public:
|
||||||
|
MaidesiteDeskNumber() = default;
|
||||||
|
void dump_config() override;
|
||||||
|
void set_id(int id) {
|
||||||
|
this->id_ = id;
|
||||||
|
}
|
||||||
|
|
||||||
namespace esphome
|
protected:
|
||||||
{
|
void control(float value) override;
|
||||||
namespace maidesite_desk
|
int id_;
|
||||||
{
|
};
|
||||||
class MaidesiteDeskNumber : public number::Number, public Component, public Parented<MaidesiteDeskComponent>
|
} // namespace maidesite_desk
|
||||||
{
|
} // namespace esphome
|
||||||
public:
|
|
||||||
MaidesiteDeskNumber() = default;
|
|
||||||
void dump_config() override;
|
|
||||||
void set_id(int id) { this->id_ = id; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void control(float value) override;
|
|
||||||
int id_;
|
|
||||||
};
|
|
||||||
} // namespace maidesite_desk
|
|
||||||
} // namespace esphome
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.components import sensor
|
from esphome.components import sensor
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
UNIT_CENTIMETER,
|
UNIT_CENTIMETER,
|
||||||
UNIT_PERCENT,
|
UNIT_PERCENT,
|
||||||
)
|
)
|
||||||
from .. import CONF_MAIDESITE_DESK_ID, MaidesiteDeskComponent, maidesite_desk_ns
|
from .. import CONF_MAIDESITE_DESK_ID, MaidesiteDeskComponent, maidesite_desk_ns
|
||||||
|
|
||||||
|
|
@ -18,73 +18,74 @@ CONF_POSITION_M3 = "position_m3"
|
||||||
CONF_POSITION_M4 = "position_m4"
|
CONF_POSITION_M4 = "position_m4"
|
||||||
|
|
||||||
TYPES = [
|
TYPES = [
|
||||||
CONF_UNIT,
|
CONF_UNIT,
|
||||||
CONF_HEIGHT_ABS,
|
CONF_HEIGHT_ABS,
|
||||||
CONF_HEIGHT_PCT,
|
CONF_HEIGHT_PCT,
|
||||||
CONF_HEIGHT_MIN,
|
CONF_HEIGHT_MIN,
|
||||||
CONF_HEIGHT_MAX,
|
CONF_HEIGHT_MAX,
|
||||||
CONF_POSITION_M1,
|
CONF_POSITION_M1,
|
||||||
CONF_POSITION_M2,
|
CONF_POSITION_M2,
|
||||||
CONF_POSITION_M3,
|
CONF_POSITION_M3,
|
||||||
CONF_POSITION_M4,
|
CONF_POSITION_M4,
|
||||||
]
|
]
|
||||||
|
|
||||||
MaidesiteDeskSensor = maidesite_desk_ns.class_("MaidesiteDeskSensor", sensor.Sensor, cg.Component)
|
MaidesiteDeskSensor = maidesite_desk_ns.class_(
|
||||||
|
"MaidesiteDeskSensor", sensor.Sensor, cg.Component
|
||||||
|
)
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.Schema(
|
CONFIG_SCHEMA = cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_MAIDESITE_DESK_ID): cv.use_id(MaidesiteDeskComponent),
|
cv.GenerateID(CONF_MAIDESITE_DESK_ID): cv.use_id(MaidesiteDeskComponent),
|
||||||
|
cv.Optional(CONF_UNIT): sensor.sensor_schema(),
|
||||||
cv.Optional(CONF_UNIT): sensor.sensor_schema(),
|
cv.Optional(CONF_HEIGHT_ABS): sensor.sensor_schema(
|
||||||
|
MaidesiteDeskSensor,
|
||||||
cv.Optional(CONF_HEIGHT_ABS): sensor.sensor_schema(
|
accuracy_decimals=2,
|
||||||
MaidesiteDeskSensor,
|
unit_of_measurement=UNIT_CENTIMETER,
|
||||||
accuracy_decimals=2,
|
),
|
||||||
unit_of_measurement=UNIT_CENTIMETER,
|
cv.Optional(CONF_HEIGHT_PCT): sensor.sensor_schema(
|
||||||
),
|
MaidesiteDeskSensor,
|
||||||
cv.Optional(CONF_HEIGHT_PCT): sensor.sensor_schema(
|
accuracy_decimals=2,
|
||||||
MaidesiteDeskSensor,
|
unit_of_measurement=UNIT_PERCENT,
|
||||||
accuracy_decimals=2,
|
),
|
||||||
unit_of_measurement=UNIT_PERCENT,
|
cv.Optional(CONF_HEIGHT_MIN): sensor.sensor_schema(
|
||||||
),
|
MaidesiteDeskSensor,
|
||||||
cv.Optional(CONF_HEIGHT_MIN): sensor.sensor_schema(
|
accuracy_decimals=2,
|
||||||
MaidesiteDeskSensor,
|
unit_of_measurement=UNIT_CENTIMETER,
|
||||||
accuracy_decimals=2,
|
),
|
||||||
unit_of_measurement=UNIT_CENTIMETER,
|
cv.Optional(CONF_HEIGHT_MAX): sensor.sensor_schema(
|
||||||
),
|
MaidesiteDeskSensor,
|
||||||
cv.Optional(CONF_HEIGHT_MAX): sensor.sensor_schema(
|
accuracy_decimals=2,
|
||||||
MaidesiteDeskSensor,
|
unit_of_measurement=UNIT_CENTIMETER,
|
||||||
accuracy_decimals=2,
|
),
|
||||||
unit_of_measurement=UNIT_CENTIMETER,
|
cv.Optional(CONF_POSITION_M1): sensor.sensor_schema(
|
||||||
),
|
MaidesiteDeskSensor,
|
||||||
cv.Optional(CONF_POSITION_M1): sensor.sensor_schema(
|
accuracy_decimals=2,
|
||||||
MaidesiteDeskSensor,
|
unit_of_measurement=UNIT_CENTIMETER,
|
||||||
accuracy_decimals=2,
|
),
|
||||||
unit_of_measurement=UNIT_CENTIMETER,
|
cv.Optional(CONF_POSITION_M2): sensor.sensor_schema(
|
||||||
),
|
MaidesiteDeskSensor,
|
||||||
cv.Optional(CONF_POSITION_M2): sensor.sensor_schema(
|
accuracy_decimals=2,
|
||||||
MaidesiteDeskSensor,
|
unit_of_measurement=UNIT_CENTIMETER,
|
||||||
accuracy_decimals=2,
|
),
|
||||||
unit_of_measurement=UNIT_CENTIMETER,
|
cv.Optional(CONF_POSITION_M3): sensor.sensor_schema(
|
||||||
),
|
MaidesiteDeskSensor,
|
||||||
cv.Optional(CONF_POSITION_M3): sensor.sensor_schema(
|
accuracy_decimals=2,
|
||||||
MaidesiteDeskSensor,
|
unit_of_measurement=UNIT_CENTIMETER,
|
||||||
accuracy_decimals=2,
|
),
|
||||||
unit_of_measurement=UNIT_CENTIMETER,
|
cv.Optional(CONF_POSITION_M4): sensor.sensor_schema(
|
||||||
),
|
MaidesiteDeskSensor,
|
||||||
cv.Optional(CONF_POSITION_M4): sensor.sensor_schema(
|
accuracy_decimals=2,
|
||||||
MaidesiteDeskSensor,
|
unit_of_measurement=UNIT_CENTIMETER,
|
||||||
accuracy_decimals=2,
|
),
|
||||||
unit_of_measurement=UNIT_CENTIMETER,
|
}
|
||||||
),
|
|
||||||
}
|
|
||||||
).extend(cv.COMPONENT_SCHEMA)
|
).extend(cv.COMPONENT_SCHEMA)
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
hub = await cg.get_variable(config[CONF_MAIDESITE_DESK_ID])
|
hub = await cg.get_variable(config[CONF_MAIDESITE_DESK_ID])
|
||||||
for key in TYPES:
|
for key in TYPES:
|
||||||
if child_config := config.get(key):
|
if child_config := config.get(key):
|
||||||
var = await sensor.new_sensor(child_config)
|
var = await sensor.new_sensor(child_config)
|
||||||
await cg.register_component(var, child_config)
|
await cg.register_component(var, child_config)
|
||||||
await cg.register_parented(var, config[CONF_MAIDESITE_DESK_ID])
|
await cg.register_parented(var, config[CONF_MAIDESITE_DESK_ID])
|
||||||
cg.add(getattr(hub, f"set_{key}_sensor")(var))
|
cg.add(getattr(hub, f"set_{key}_sensor")(var))
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
#include "maidesite_desk_sensor.h"
|
#include "maidesite_desk_sensor.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
|
namespace maidesite_desk {
|
||||||
|
static const char* const TAG = "maidesite_desk.sensor";
|
||||||
|
|
||||||
namespace esphome
|
void MaidesiteDeskSensor::dump_config() {
|
||||||
{
|
LOG_SENSOR("", "Maidesite Desk Sensor", this);
|
||||||
namespace maidesite_desk
|
delay(10);
|
||||||
{
|
}
|
||||||
static const char *const TAG = "maidesite_desk.sensor";
|
} // namespace maidesite_desk
|
||||||
|
} // namespace esphome
|
||||||
void MaidesiteDeskSensor::dump_config()
|
|
||||||
{
|
|
||||||
LOG_SENSOR("", "Maidesite Desk Sensor", this);
|
|
||||||
delay(10);
|
|
||||||
}
|
|
||||||
} // namespace maidesite_desk
|
|
||||||
} // namespace esphome
|
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,12 @@
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
#include "../maidesite_desk.h"
|
#include "../maidesite_desk.h"
|
||||||
|
|
||||||
|
namespace esphome {
|
||||||
namespace esphome
|
namespace maidesite_desk {
|
||||||
{
|
class MaidesiteDeskSensor : public sensor::Sensor, public Component, public Parented<MaidesiteDeskComponent> {
|
||||||
namespace maidesite_desk
|
public:
|
||||||
{
|
MaidesiteDeskSensor() = default;
|
||||||
class MaidesiteDeskSensor : public sensor::Sensor, public Component, public Parented<MaidesiteDeskComponent>
|
void dump_config() override;
|
||||||
{
|
};
|
||||||
public:
|
} // namespace maidesite_desk
|
||||||
MaidesiteDeskSensor() = default;
|
} // namespace esphome
|
||||||
void dump_config() override;
|
|
||||||
};
|
|
||||||
} // namespace maidesite_desk
|
|
||||||
} // namespace esphome
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue