mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
[Modbus_controller] Fix binary sensor lambda (#3020)
This commit is contained in:
parent
9e8b701dea
commit
e55bd1e559
2 changed files with 3 additions and 4 deletions
|
@ -57,4 +57,4 @@ async def to_code(config):
|
||||||
|
|
||||||
paren = await cg.get_variable(config[CONF_MODBUS_CONTROLLER_ID])
|
paren = await cg.get_variable(config[CONF_MODBUS_CONTROLLER_ID])
|
||||||
cg.add(paren.add_sensor_item(var))
|
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)
|
||||||
|
|
|
@ -31,12 +31,11 @@ class ModbusBinarySensor : public Component, public binary_sensor::BinarySensor,
|
||||||
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
using transform_func_t =
|
using transform_func_t = std::function<optional<bool>(ModbusBinarySensor *, bool, const std::vector<uint8_t> &)>;
|
||||||
optional<std::function<optional<bool>(ModbusBinarySensor *, bool, const std::vector<uint8_t> &)>>;
|
|
||||||
void set_template(transform_func_t &&f) { this->transform_func_ = f; }
|
void set_template(transform_func_t &&f) { this->transform_func_ = f; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
transform_func_t transform_func_{nullopt};
|
optional<transform_func_t> transform_func_{nullopt};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace modbus_controller
|
} // namespace modbus_controller
|
||||||
|
|
Loading…
Reference in a new issue