diff --git a/esphome/components/modbus_controller/binary_sensor/__init__.py b/esphome/components/modbus_controller/binary_sensor/__init__.py index 99d56fed67..557d76479d 100644 --- a/esphome/components/modbus_controller/binary_sensor/__init__.py +++ b/esphome/components/modbus_controller/binary_sensor/__init__.py @@ -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) diff --git a/esphome/components/modbus_controller/binary_sensor/modbus_binarysensor.h b/esphome/components/modbus_controller/binary_sensor/modbus_binarysensor.h index c516d6b916..21afbc7053 100644 --- a/esphome/components/modbus_controller/binary_sensor/modbus_binarysensor.h +++ b/esphome/components/modbus_controller/binary_sensor/modbus_binarysensor.h @@ -31,12 +31,11 @@ class ModbusBinarySensor : public Component, public binary_sensor::BinarySensor, void dump_config() override; - using transform_func_t = - optional(ModbusBinarySensor *, bool, const std::vector &)>>; + using transform_func_t = std::function(ModbusBinarySensor *, bool, const std::vector &)>; void set_template(transform_func_t &&f) { this->transform_func_ = f; } protected: - transform_func_t transform_func_{nullopt}; + optional transform_func_{nullopt}; }; } // namespace modbus_controller