Skip to content

Commit

Permalink
refine number entity (m3_vedirect)
Browse files Browse the repository at this point in the history
  • Loading branch information
krahabb committed Nov 30, 2024
1 parent 61a6475 commit a5dfd17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 10 additions & 6 deletions esphome/components/m3_vedirect/number/number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ void Number::control(float value) {

void Number::request_callback_(void *callback_param, const RxHexFrame *hex_frame) {
Number *_number = reinterpret_cast<Number *>(callback_param);
if (hex_frame) {
if (hex_frame->flags()) {
// error
} else {
}
if (!hex_frame || (hex_frame && hex_frame->flags())) {
// Error or timeout..resend actual state since it looks like HA esphome does optimistic
// updates in it's HA entity instance...
_number->publish_state(_number->state);
} else {
// timed out
// Invalidate our state so that the subsequent dispatching/parsing goes through
// an effective publish_state. This is needed (again) since the frontend already
// optimistically updated the entity to the new value but even in case of success,
// the device might 'force' a different setting if the request was for an unsupported
// value
_number->state = NAN;
}
}

Expand Down
1 change: 0 additions & 1 deletion esphome/components/m3_vedirect/number/number.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Number final : public ConfigEntity, public NumericEntity, public Entity, p
protected:
friend class Manager;
void link_disconnected_() override;

void init_reg_def_() override;

// interface esphome::number::Number
Expand Down

0 comments on commit a5dfd17

Please sign in to comment.