[Modbus_controller] Fix binary sensor lambda (#3020)

This commit is contained in:
Martin 2022-01-10 00:29:29 +01:00 committed by GitHub
parent 9e8b701dea
commit e55bd1e559
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View file

@ -57,4 +57,4 @@ async def to_code(config):
paren = await cg.get_variable(config[CONF_MODBUS_CONTROLLER_ID])
cg.add(paren.add_sensor_item(var))
await add_modbus_base_properties(var, config, ModbusBinarySensor, cg.float_, bool)
await add_modbus_base_properties(var, config, ModbusBinarySensor, bool, bool)

View file

@ -31,12 +31,11 @@ class ModbusBinarySensor : public Component, public binary_sensor::BinarySensor,
void dump_config() override;
using transform_func_t =
optional<std::function<optional<bool>(ModbusBinarySensor *, bool, const std::vector<uint8_t> &)>>;
using transform_func_t = std::function<optional<bool>(ModbusBinarySensor *, bool, const std::vector<uint8_t> &)>;
void set_template(transform_func_t &&f) { this->transform_func_ = f; }
protected:
transform_func_t transform_func_{nullopt};
optional<transform_func_t> transform_func_{nullopt};
};
} // namespace modbus_controller