mirror of
https://github.com/esphome/esphome.git
synced 2025-03-13 22:28:14 +00:00
Actions
This commit is contained in:
parent
fee7ce8396
commit
6e38a2a991
@ -11,7 +11,6 @@ static const uint8_t MHZ19_COMMAND_GET_PPM[] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x
|
||||
static const uint8_t MHZ19_COMMAND_ABC_ENABLE[] = {0xff, 0x01, 0x79, 0xA0, 0x00, 0x00, 0x00, 0x00};
|
||||
static const uint8_t MHZ19_COMMAND_ABC_DISABLE[] = {0xff, 0x01, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
static const uint8_t MHZ19_COMMAND_CALIBRATE_ZERO[] = {0xff, 0x01, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
static const uint8_t MHZ19_COMMAND_CALIBRATE_SPAN[] = {0xff, 0x01, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
uint8_t mhz19_checksum(const uint8_t *command) {
|
||||
uint8_t sum = 0;
|
||||
@ -67,11 +66,6 @@ void MHZ19Component::calibrate_zero() {
|
||||
this->mhz19_write_command_(MHZ19_COMMAND_CALIBRATE_ZERO, nullptr);
|
||||
}
|
||||
|
||||
void MHZ19Component::calibrate_span() {
|
||||
ESP_LOGI(TAG, "MHZ19 Calibrating span point");
|
||||
this->mhz19_write_command_(MHZ19_COMMAND_CALIBRATE_SPAN, nullptr);
|
||||
}
|
||||
|
||||
void MHZ19Component::abc_enable() {
|
||||
ESP_LOGI(TAG, "MHZ19 Enabling ABC");
|
||||
this->mhz19_write_command_(MHZ19_COMMAND_ABC_ENABLE, nullptr);
|
||||
|
@ -23,7 +23,6 @@ class MHZ19Component : public PollingComponent, public uart::UARTDevice {
|
||||
void dump_config() override;
|
||||
|
||||
void calibrate_zero();
|
||||
void calibrate_span();
|
||||
void abc_enable();
|
||||
void abc_disable();
|
||||
|
||||
@ -48,15 +47,6 @@ template<typename... Ts> class MHZ19CalibrateZeroAction : public Action<Ts...> {
|
||||
MHZ19Component *mhz19_;
|
||||
};
|
||||
|
||||
template<typename... Ts> class MHZ19CalibrateSpanAction : public Action<Ts...> {
|
||||
public:
|
||||
MHZ19CalibrateSpanAction(MHZ19Component *mhz19) : mhz19_(mhz19) {}
|
||||
void play(Ts... x) override { this->mhz19_->calibrate_span(); }
|
||||
|
||||
protected:
|
||||
MHZ19Component *mhz19_;
|
||||
};
|
||||
|
||||
template<typename... Ts> class MHZ19ABCEnableAction : public Action<Ts...> {
|
||||
public:
|
||||
MHZ19ABCEnableAction(MHZ19Component *mhz19) : mhz19_(mhz19) {}
|
||||
|
@ -13,7 +13,6 @@ CONF_AUTOMATIC_BASELINE_CALIBRATION = 'automatic_baseline_calibration'
|
||||
mhz19_ns = cg.esphome_ns.namespace('mhz19')
|
||||
MHZ19Component = mhz19_ns.class_('MHZ19Component', cg.PollingComponent, uart.UARTDevice)
|
||||
MHZ19CalibrateZeroAction = mhz19_ns.class_('MHZ19CalibrateZeroAction', automation.Action)
|
||||
MHZ19CalibrateSpanAction = mhz19_ns.class_('MHZ19CalibrateSpanAction', automation.Action)
|
||||
MHZ19ABCEnableAction = mhz19_ns.class_('MHZ19ABCEnableAction', automation.Action)
|
||||
MHZ19ABCDisableAction = mhz19_ns.class_('MHZ19ABCDisableAction', automation.Action)
|
||||
|
||||
@ -48,7 +47,6 @@ CALIBRATION_ACTION_SCHEMA = maybe_simple_id({
|
||||
|
||||
|
||||
@automation.register_action('mhz19.calibrate_zero', MHZ19CalibrateZeroAction, CALIBRATION_ACTION_SCHEMA)
|
||||
@automation.register_action('mhz19.calibrate_span', MHZ19CalibrateSpanAction, CALIBRATION_ACTION_SCHEMA)
|
||||
@automation.register_action('mhz19.abc_enable', MHZ19ABCEnableAction, CALIBRATION_ACTION_SCHEMA)
|
||||
@automation.register_action('mhz19.abc_disable', MHZ19ABCDisableAction, CALIBRATION_ACTION_SCHEMA)
|
||||
def mhz19_calibration_to_code(config, action_id, template_arg, args):
|
||||
|
Loading…
x
Reference in New Issue
Block a user