'Update the state of the sensor.'

def update(self):

    if (self._register_type == REGISTER_TYPE_INPUT):
        result = modbus.HUB.read_input_registers(self._slave, self._register, self._count)
    else:
        result = modbus.HUB.read_holding_registers(self._slave, self._register, self._count)
    val = 0
    try:
        registers = result.registers
    except AttributeError:
        _LOGGER.error('No    response    from    modbus    slave    %s    register    %s', self._slave, self._register)
        return
    if (self._data_type == DATA_TYPE_FLOAT):
        byte_string = ''.join([x.to_bytes(2, byteorder='big') for x in registers])
        val = struct.unpack('>f', byte_string)[0]
    elif (self._data_type == DATA_TYPE_INT):
        for (i, res) in enumerate(registers):
            val += (res * (2 ** (i * 16)))
    self._value = format(((self._scale * val) + self._offset), '.{}f'.format(self._precision))
