Esempio n. 1
0
    def __init__(self, node_id, node_type, modbus_hub):
        """Initialize Node base."""
        self._node_id = int(node_id)
        self._node_type = ModuleType(node_type)
        self._child_nodes = []
        # registers
        # name, register, register_type,
        # unit_of_measurement, count, scale, offset, data_type, precision
        # input
        self._reg_status = ModbusRegister(
            modbus_hub, 'Zone status',
            to_register_addr(self._node_id, DUCO_REG_ADDR_INPUT_STATUS),
            REGISTER_TYPE_INPUT, '', 1, 1, 0, DATA_TYPE_INT, 0)

        self._reg_fan_actual = ModbusRegister(
            modbus_hub, 'Fan actual',
            to_register_addr(self._node_id, DUCO_REG_ADDR_INPUT_FAN_ACTUAL),
            REGISTER_TYPE_INPUT, '%', 1, 1, 0, DATA_TYPE_INT, 0)

        self._reg_zone = ModbusRegister(
            modbus_hub, 'Zone',
            to_register_addr(self._node_id, DUCO_REG_ADDR_INPUT_GROUP),
            REGISTER_TYPE_INPUT, '', 1, 1, 0, DATA_TYPE_INT, 0)
        # holding
        self._reg_setpoint = ModbusRegister(
            modbus_hub, 'Zone setpoint',
            to_register_addr(self._node_id, DUCO_REG_ADDR_HOLD_FAN_SETPOINT),
            REGISTER_TYPE_HOLDING, '%', 1, 1, 0, DATA_TYPE_INT, 0)

        self._reg_action = ModbusRegister(
            modbus_hub, 'Zone action',
            to_register_addr(self._node_id, DUCO_REG_ADDR_HOLD_ACTION),
            REGISTER_TYPE_HOLDING, '', 1, 1, 0, DATA_TYPE_INT, 0)
Esempio n. 2
0
    def __init__(self, node_id, modbus_hub):
        """Initialize AutoMinMaxCapable."""
        self._reg_automin = ModbusRegister(
            modbus_hub, 'AutoMin',
            to_register_addr(node_id, DUCO_REG_ADDR_HOLD_AUTOMIN),
            REGISTER_TYPE_HOLDING, '%', 1, 1, 0, DATA_TYPE_INT, 0)

        self._reg_automax = ModbusRegister(
            modbus_hub, 'AutoMax',
            to_register_addr(node_id, DUCO_REG_ADDR_HOLD_AUTOMAX),
            REGISTER_TYPE_HOLDING, '%', 1, 1, 0, DATA_TYPE_INT, 0)
Esempio n. 3
0
 def __init__(self, node_id, modbus_hub):
     """Initialize CO2Sensor base class."""
     # input
     self._reg_co2_value = ModbusRegister(
         modbus_hub, 'CO2 value',
         to_register_addr(node_id, DUCO_REG_ADDR_INPUT_CO2_ACTUAL),
         REGISTER_TYPE_INPUT, 'ppm', 1, 1, 0, DATA_TYPE_INT, 0)
     # holding
     self._reg_co2_setpoint = ModbusRegister(
         modbus_hub, 'CO2 setpoint',
         to_register_addr(node_id, DUCO_REG_ADDR_HOLD_CO2_SETPOINT),
         REGISTER_TYPE_HOLDING, 'ppm', 1, 1, 0, DATA_TYPE_INT, 0)
Esempio n. 4
0
 def __init__(self, node_id, modbus_hub):
     """Initialize RHSensor base class."""
     # input
     self._reg_rh_value = ModbusRegister(
         modbus_hub, 'RH value',
         to_register_addr(node_id, DUCO_REG_ADDR_INPUT_RH_ACTUAL),
         REGISTER_TYPE_INPUT, '%', 1, DUCO_RH_SCALE_FACTOR, 0,
         DATA_TYPE_INT, DUCO_RH_PRECISION)
     # holding
     self._reg_rh_setpoint = ModbusRegister(
         modbus_hub, 'RH setpoint',
         to_register_addr(node_id, DUCO_REG_ADDR_HOLD_RH_SETPOINT),
         REGISTER_TYPE_HOLDING, '%', 1, 1, 0, DATA_TYPE_INT, 0)
     self._reg_rh_delta = ModbusRegister(
         modbus_hub, 'RH delta',
         to_register_addr(node_id, DUCO_REG_ADDR_HOLD_RH_DELTA),
         REGISTER_TYPE_HOLDING, '-', 1, 1, 0, DATA_TYPE_INT, 0)
Esempio n. 5
0
 def __init__(self, node_id, modbus_hub):
     """Initialize TemperatureSensor base class."""
     # input
     self._reg_temperature = ModbusRegister(
         modbus_hub, 'Temperature',
         to_register_addr(node_id, DUCO_REG_ADDR_INPUT_TEMPERATURE),
         REGISTER_TYPE_INPUT, '°C', 1, DUCO_TEMPERATURE_SCALE_FACTOR, 0,
         DATA_TYPE_INT, DUCO_TEMPERATURE_PRECISION)
Esempio n. 6
0
 def __init__(self, node_id, modbus_hub):
     """Initialize UserController base class."""
     # holding
     self._reg_button_1 = ModbusRegister(
         modbus_hub, 'Button 1',
         to_register_addr(node_id, DUCO_REG_ADDR_HOLD_BUTTON_1),
         REGISTER_TYPE_HOLDING, '%', 1, 1, 0, DATA_TYPE_INT, 0)
     self._reg_button_2 = ModbusRegister(
         modbus_hub, 'Button 2',
         to_register_addr(node_id, DUCO_REG_ADDR_HOLD_BUTTON_2),
         REGISTER_TYPE_HOLDING, '%', 1, 1, 0, DATA_TYPE_INT, 0)
     self._reg_button_3 = ModbusRegister(
         modbus_hub, 'Button 3',
         to_register_addr(node_id, DUCO_REG_ADDR_HOLD_BUTTON_3),
         REGISTER_TYPE_HOLDING, '%', 1, 1, 0, DATA_TYPE_INT, 0)
     self._reg_manual_time = ModbusRegister(
         modbus_hub, 'Manual time',
         to_register_addr(node_id, DUCO_REG_ADDR_HOLD_MANUAL_TIME),
         REGISTER_TYPE_HOLDING, 'minutes', 1, 1, 0, DATA_TYPE_INT, 0)
Esempio n. 7
0
    def __init__(self, node_id, node_type, modbus_hub):
        """Initialize Valve base class."""
        Node.__init__(self, node_id, node_type, modbus_hub)
        AutoMinMaxCapable.__init__(self, node_id, modbus_hub)
        TemperatureSensor.__init__(self, node_id, modbus_hub)

        # holding
        self._reg_flow = ModbusRegister(
            modbus_hub, 'Flow',
            to_register_addr(self._node_id, DUCO_REG_ADDR_HOLD_FLOW),
            REGISTER_TYPE_HOLDING, 'm3/h', 1, 1, 0, DATA_TYPE_INT, 0)
Esempio n. 8
0
    def __probe_node_id(self, node_id):
        """Probe Modbus for node_id module type."""
        _LOGGER.debug("probe node_id %d", node_id)
        modbus_result = self._modbus_hub.read_input_registers(
            to_register_addr(node_id, DUCO_REG_ADDR_INPUT_MODULE_TYPE), 1)
        try:
            register = modbus_result.registers
            response = register[0]
        except AttributeError:
            _LOGGER.debug("No response from node_id %d", node_id)
            return False

        if ModuleType.supported(response):
            module_type = ModuleType(response)
            _LOGGER.debug("node_id %d is a module of type %s", node_id,
                          module_type)
            return module_type

        return False