Cleanup
This commit is contained in:
parent
d3a8549fab
commit
cebeacbd3c
|
@ -5,6 +5,9 @@
|
|||
namespace esphome {
|
||||
namespace ratgdo {
|
||||
|
||||
using protocol::SetRollingCodeCounter;
|
||||
using protocol::SetClientID;
|
||||
|
||||
float normalize_client_id(float client_id)
|
||||
{
|
||||
uint32_t int_value = static_cast<uint32_t>(client_id);
|
||||
|
@ -84,6 +87,9 @@ namespace ratgdo {
|
|||
|
||||
void RATGDONumber::update_state(float value)
|
||||
{
|
||||
if (value == this->state) {
|
||||
return;
|
||||
}
|
||||
this->pref_.save(&value);
|
||||
this->publish_state(value);
|
||||
}
|
||||
|
@ -91,14 +97,14 @@ namespace ratgdo {
|
|||
void RATGDONumber::control(float value)
|
||||
{
|
||||
if (this->number_type_ == RATGDO_ROLLING_CODE_COUNTER) {
|
||||
this->parent_->set_rolling_code_counter(value);
|
||||
this->parent_->call_protocol(SetRollingCodeCounter{static_cast<uint32_t>(value)});
|
||||
} else if (this->number_type_ == RATGDO_OPENING_DURATION) {
|
||||
this->parent_->set_opening_duration(value);
|
||||
} else if (this->number_type_ == RATGDO_CLOSING_DURATION) {
|
||||
this->parent_->set_closing_duration(value);
|
||||
} else if (this->number_type_ == RATGDO_CLIENT_ID) {
|
||||
value = normalize_client_id(value);
|
||||
this->parent_->set_client_id(value);
|
||||
this->parent_->call_protocol(SetClientID{static_cast<uint32_t>(value)});
|
||||
}
|
||||
this->update_state(value);
|
||||
}
|
||||
|
|
|
@ -312,16 +312,9 @@ namespace ratgdo {
|
|||
this->closing_duration = duration;
|
||||
}
|
||||
|
||||
void RATGDOComponent::set_rolling_code_counter(uint32_t counter)
|
||||
Result RATGDOComponent::call_protocol(Args args)
|
||||
{
|
||||
|
||||
ESP_LOGV(TAG, "Set rolling code counter to %d", counter);
|
||||
this->protocol_->call(SetRollingCodeCounter{counter});
|
||||
}
|
||||
|
||||
void RATGDOComponent::set_client_id(uint64_t client_id)
|
||||
{
|
||||
this->protocol_->call(SetClientID{client_id});
|
||||
return this->protocol_->call(args);
|
||||
}
|
||||
|
||||
/*************************** OBSTRUCTION DETECTION ***************************/
|
||||
|
|
|
@ -43,8 +43,12 @@ namespace ratgdo {
|
|||
}
|
||||
};
|
||||
|
||||
using protocol::Args;
|
||||
using protocol::Result;
|
||||
|
||||
class RATGDOComponent : public Component {
|
||||
public:
|
||||
|
||||
void setup() override;
|
||||
void loop() override;
|
||||
void dump_config() override;
|
||||
|
@ -88,9 +92,7 @@ namespace ratgdo {
|
|||
void set_input_gdo_pin(InternalGPIOPin* pin) { this->input_gdo_pin_ = pin; }
|
||||
void set_input_obst_pin(InternalGPIOPin* pin) { this->input_obst_pin_ = pin; }
|
||||
|
||||
// security+2.0 specific
|
||||
void set_rolling_code_counter(uint32_t code);
|
||||
void set_client_id(uint64_t client_id);
|
||||
Result call_protocol(Args args);
|
||||
|
||||
void received(const DoorState door_state);
|
||||
void received(const LightState light_state);
|
||||
|
|
Loading…
Reference in New Issue