#pragma once #include #include #include "esphome/components/modbus_controller/modbus_controller.h" #include "esphome/components/select/select.h" #include "esphome/core/component.h" namespace esphome { namespace neopool { /** * @brief Controls the filtration mode of the Neopool device connected via modbus * * Possible states: * - automatic * - off * - slow * - medium * - fast * * To read the state: * reads relay register 0x010E, with bitmasks * - 0x0100 slow * - 0x0200 medium * - 0x0400 high * - 0x0010 filtering * auto / non-auto: 0x0411: * - MBV_PAR_FILT_MANUAL = 0, // This mode allows to turn the filtration (and all other systems that depend on it) on and off manually. * MBV_PAR_FILT_AUTO = 1, // This mode allows filtering to be turned on and off according to the settings of the TIMER1, TIMER2 and TIMER3 timers. * * To set the manual state: * set filtration speed to addr 0x050F (MBF_PAR_FILTRATION_CONF), register needs to be read first to be correctly modified * set MBF_EXEC to 1 * set filtration mode to manual (=0) via MBF_PAR_FILT_MODE (0x0411) * set manual mode filtration to on 0x0413 to 0, 1, 2, ? * */ class FiltrationMode : public Component, public select::Select { public: void set_parent(ModbusController *const parent) { this->parent_ = parent; } void dump_config() override; void control(const std::string &value) override; protected: ModbusController *parent_; }; } // namespace modbus_controller } // namespace esphome