[modbus_controller] add missing skip_updates (#3063)

This commit is contained in:
Martin 2022-01-17 21:05:13 +01:00 committed by GitHub
parent 514204f0d4
commit cdb4fa2487
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -18,6 +18,7 @@ from ..const import (
CONF_FORCE_NEW_RANGE, CONF_FORCE_NEW_RANGE,
CONF_MODBUS_CONTROLLER_ID, CONF_MODBUS_CONTROLLER_ID,
CONF_REGISTER_TYPE, CONF_REGISTER_TYPE,
CONF_SKIP_UPDATES,
CONF_USE_WRITE_MULTIPLE, CONF_USE_WRITE_MULTIPLE,
CONF_WRITE_LAMBDA, CONF_WRITE_LAMBDA,
) )
@ -53,6 +54,7 @@ async def to_code(config):
config[CONF_ADDRESS], config[CONF_ADDRESS],
byte_offset, byte_offset,
config[CONF_BITMASK], config[CONF_BITMASK],
config[CONF_SKIP_UPDATES],
config[CONF_FORCE_NEW_RANGE], config[CONF_FORCE_NEW_RANGE],
) )
await cg.register_component(var, config) await cg.register_component(var, config)

View File

@ -10,14 +10,14 @@ namespace modbus_controller {
class ModbusSwitch : public Component, public switch_::Switch, public SensorItem { class ModbusSwitch : public Component, public switch_::Switch, public SensorItem {
public: public:
ModbusSwitch(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask, ModbusSwitch(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask,
bool force_new_range) uint8_t skip_updates, bool force_new_range)
: Component(), switch_::Switch() { : Component(), switch_::Switch() {
this->register_type = register_type; this->register_type = register_type;
this->start_address = start_address; this->start_address = start_address;
this->offset = offset; this->offset = offset;
this->bitmask = bitmask; this->bitmask = bitmask;
this->sensor_value_type = SensorValueType::BIT; this->sensor_value_type = SensorValueType::BIT;
this->skip_updates = 0; this->skip_updates = skip_updates;
this->register_count = 1; this->register_count = 1;
if (register_type == ModbusRegisterType::HOLDING || register_type == ModbusRegisterType::COIL) { if (register_type == ModbusRegisterType::HOLDING || register_type == ModbusRegisterType::COIL) {
this->start_address += offset; this->start_address += offset;