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