2023-06-07 23:10:02 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../ratgdo.h"
|
|
|
|
#include "../ratgdo_state.h"
|
|
|
|
#include "esphome/components/number/number.h"
|
|
|
|
#include "esphome/core/component.h"
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
namespace ratgdo {
|
|
|
|
|
|
|
|
enum NumberType {
|
2023-10-26 17:04:35 +00:00
|
|
|
RATGDO_CLIENT_ID,
|
2023-06-25 23:03:39 +00:00
|
|
|
RATGDO_ROLLING_CODE_COUNTER,
|
|
|
|
RATGDO_OPENING_DURATION,
|
|
|
|
RATGDO_CLOSING_DURATION,
|
2023-06-07 23:10:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RATGDONumber : public number::Number, public RATGDOClient, public Component {
|
|
|
|
public:
|
|
|
|
void dump_config() override;
|
2023-07-01 14:13:38 +00:00
|
|
|
void setup() override;
|
2023-07-07 22:56:12 +00:00
|
|
|
void set_number_type(NumberType number_type);
|
|
|
|
// other esphome components that persist state in the flash have HARDWARE priority
|
|
|
|
// ensure we get initialized before them, so that the state doesn't get invalidated
|
|
|
|
// by components that might be added in the future
|
|
|
|
float get_setup_priority() const override { return setup_priority::HARDWARE + 1; }
|
2023-06-07 23:10:02 +00:00
|
|
|
|
2023-07-07 22:56:12 +00:00
|
|
|
void update_state(float value);
|
2023-06-07 23:13:58 +00:00
|
|
|
void control(float value) override;
|
2023-06-07 23:10:02 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
NumberType number_type_;
|
2023-07-07 22:56:12 +00:00
|
|
|
ESPPreferenceObject pref_;
|
2023-06-07 23:10:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ratgdo
|
|
|
|
} // namespace esphome
|